BBC BASIC for Windows
Programming >> BBC BASIC language >> Randomness
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1484824484

Randomness
Post by KenDown on Jan 19th, 2017, 10:14am

Does anyone know whether the RND algorithm has changed at all over the years?

The reason I ask is because I have an encryption program I wrote which uses RND. Enter the password, the program converts it to a numeric value, then seeds RND with the negative value. In theory every run of RND should produce the same numbers.

It has worked fine, but recently I tried to open an old document that had been encrypted with this method and the first couple of lines decrypted just fine, but the rest was garbage.

I'm running 6.02, but still have 5.95 and the same problem occurs with both.
Re: Randomness
Post by DDRM on Jan 19th, 2017, 1:55pm

Not as far as I know - and I'd be very surprised if Richard changed it without notice, for exactly this kind of reason. You could ask him directly, or on the other forum.

I think it's a linear congruential generator, and I'm sure we've discussed the algorithm in the past - you could probably find the equation on the groups.io site (which has all the old Yahoo postings), if it's not on this one, allowing you to implement it directly.

Do you have any other files encrypted the same way? Do they work? I'd have thought the more likely explanation is a corruption of the document file - particularly if the first few lines translate correctly.

If you add or remove one character at the point where the translation breaks down, can you rescue it?

Best wishes,

D
Re: Randomness
Post by KenDown on Jan 19th, 2017, 7:55pm

Thanks for the suggestion. Yes, I have lots of other files encrypted in this way and all without problems - but they are more recent that this one.