Am 01.07.2014 15:30, schrieb Le_Forgeron:
> Le 01/07/2014 14:23, Lars Rohwedder a écrit :
>> I've seen a simple encryption like this:
>>
>> uint64_t poor_encrypt(uint64_t x)
>> {
>> x = x ^ SECRET1;
>> x = x * SECRET2;
>> x = x ^ SECRET3;
>> return x;
>> }
>>
>> the decryption is just the reverse:
>>
>> uint64_t poor_decrypt(uint64_t x)
>> {
>> x = x ^ SECRET3;
>> x = x * INVERSE_OF_SECRET2;
>> x = x ^ SECRET1;
>> return x;
>> }
>>
>
> Which value of Secret2 would allow the * (without overloading) to
> reverse the value with a value of Inverse_of_secret2.
if SECRET2 is be 123456789, its inverse is 16969517551553616445.
It is just the "multiplicative inverse modulo 2^64".
Note the arithmetics of unsigned integer data types is always "modulo"
2^BITSIZE of that data type.
Lars R.
Post a reply to this message
|