Is there any way on the TI-84 calculators to create a "true" random number generator? I know the one built into the calculator is a pseudo-random number generator but is it at all possible to create a true RNG so that no matter what the user wants to seed the built in RNG with the result will always be random and not predictable even if they reseed it with the same seed after getting a set of numbers? My initial thought was to use the RNG in a For
loop like this to randomize the seed but it occurred to me that by seeding the initial RNG it's still predictable. Here is the code I was using:
For(I,1,int(rand*100),1)
int(rand*100)→rand
End
But as I stated that didn't work.
If you want to know this for security purposes (meaning secure from the user), consider that a TI-BASIC program is both inspectable and editable. Also when "protected" (which hides the program from the EDIT menu), which is as easy to undo as it is to "protect" the program in the first place.
The low bits of the R register are often considered "random enough", of course they are not really random, but under normal circumstances they are difficult to predict as any instruction the CPU executes also increments R by some amount, and on a macroscopic scale it is hard to predict what exactly the CPU will execute. Essentially it's like a clock but it changes more quickly and is more difficult to predict.
You could get the contents of R in a form usable from BASIC like this (you can AsmComp(
it to save space)
:AsmPrgmED5FE63FEF8C47EFBF4AC9
Which corresponds to this snippet:
ld a, r
and $3F
bcall(_SETXXOP1)
bcall(_StoAns)
ret
As you can see, the result will be in Ans
.
As long as a user runs the program without modifications, they will not be likely to guess the result (about a 1/64 chance), and even less likely to influence it in a directed way.