[fpc-pascal] Why is Random(255) some 529x slower compared to Delphi 7?

Dimitri Smits smitco at telenet.be
Fri Dec 9 11:50:01 CET 2011


----- "Graeme Geldenhuys" <graemeg.lists at gmail.com> schreef:

> On 9 December 2011 10:42, Felipe Monteiro de Carvalho  wrote:
> >
> > It is specifically written in the Delphi documentation that Random
> > should not be utilized for encryption...
> 
> Delphi documentation mentions a lot of things you mustn't do... Does
> that stop anybody. ;-)

only those that take their jobs seriously and read help/manuals iso assuming? :-)

> Like I said, I didn't write that code, and I don't specialise in
> encryption algorithms. But Florian might be right, the RandSeed
> assignment might have been added due to the bad random generator of
> Delphi - hopefully the original author of the code can shed some
> light.
> 

I actually doubt that that codesnippet does any real encryption. From what I understand from it (with the provided code and assuming types), the source-message is bitstreamed. In the resulting message, the LSB of every octet/byte/8-bitvalue is the one you need to focus on, the rest is random data. Also, as a result, the result-message is 8 times as large. And that LSB is also easily decrypted => 
parse the LSB from every byte in your data and reconstruct using OR the (index mod 8)-th bit on the (index div 8) octet.

hardly encrypted ;-)

kind regards,
Dimitri Smits



More information about the fpc-pascal mailing list