POV-Ray : Newsgroups : povray.off-topic : How to break a simple "encryption"? : Re: How to break a simple "encryption"? Server Time
28 Jul 2024 10:27:36 EDT (-0400)
  Re: How to break a simple "encryption"?  
From: Lars Rohwedder
Date: 3 Jul 2014 08:06:42
Message: <53b54752$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.