Author Topic: RANDOM and URANDOM bytes on demand  (Read 3177 times)

0 Members and 1 Guest are viewing this topic.

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
RANDOM and URANDOM bytes on demand
« on: November 07, 2021, 06:53:56 pm »
About a year ago, I got into a cryptology suite program.

I had FITS trying to make LINUX give me "CPU random bytes" that I *knew* were there, and all the big cryptology progs run off of the same bytes I am going to get...

I only needed to, periodically, stop and get a "new key pool".
IE, I need "x" bytes of completely random, mathematically random, distribution.
(software can bust you immediately, if you only PRETEND and use a RND statement, BTW)

so, this little GEM? took me *longer* than I will admit to publicly, to get
(learning LINUX as I go)

yeah, I know, your AI is *fine* with RND*256 random choices, yields 0-255;
this is for when you need "mathematically pure" random bytes. on demand.

PROGRAM:
1) runs perfect on LINUX MINT
2) most LINUX's should be okay
3) creates a couple files:

ddd, eee, fff, ggg

these contain the 1k / 4k / 64k / 1,000,000    bytes (respectively)

NOTE: if you are like me? and want to open and SEE the bytes are indeed "changing" each run?
          use "ddd" or "eee".....
          if you click on ggg, and open up 1,000,000 random bytes of gobbledygook? your little text editor might complain (mine does)

linux MINT executable :
 

got code?
Code: QB64: [Select]
  1. Print "attempting to extract 1k+4k+64k+1mb of bytes...": Print
  2. Shell "head -c 1024 /dev/urandom > ddd.dat"
  3. Print "1k successful; attempting 4k..."
  4. Shell "head -c 4096 /dev/urandom > eee.dat"
  5. Print "4k successful; attempting 64k..."
  6. Shell "head -c 65536 /dev/urandom > fff.dat"
  7. Print "64k successful; attempting 1,000,000 bytes..."
  8. Shell "head -c 1000000 /dev/urandom > ggg.dat"
  9. Print "1,000,000 bytes successful...": Print
  10. Print "check the file(s) now; program will terminate."
  11.  

NOTE: it goes w/o saying, this is LINUX only...  some windows API guy can explain how to do this in windows, please have them make a post

Offline Colonel_Panic

  • Newbie
  • Posts: 54
    • View Profile
Re: RANDOM and URANDOM bytes on demand
« Reply #1 on: November 07, 2021, 07:06:51 pm »
LINUX guys already know this, so,
this is for the people like ME...
BASIC programmers, who want to "play" on LINUX !

in DOS and BASIC.EXE terms?

in LINUX, the OS makes "special files"... its not really a FILE file, like a text file.
but... it can LOOK just like one.
sometimes? you can "open it up" and even "read" it just LIKE a regular text file?
sometimes? it says "0 bytes", but, if the G-spot is tickled just right?

it magically will poop out BYTES like you want.

PROBLEM: you can *not* OPEN the file, and read in bytes
                 you HAVE to SHELL out a "weird command" to accomplish it.

After a VERY long time beating my head against a wall, I got online, and slowly found an example...
in programming terms? I am COPYing the "magic file" to a REAL text file, and THEN I can do what I want.
here? you cant copy an empty "file", but, this command tickles the G spot correctly it poops bytes out.

(you can obviously STR$ assemble a string to designate the exact # of bytes you require per poop, in code before the SHELL)
============================================
the *rest* of my cryptology program(s)?

"run like BASIC programs"... this thing was just a way to get new pool-bytes on demand