Sponsored Content
Top Forums UNIX for Dummies Questions & Answers A crude random byte generator... Post 302855865 by wisecracker on Saturday 21st of September 2013 08:18:23 AM
Old 09-21-2013
Hi figaro...
Quote:
The quality of the output of the algorithm is also very sensitive to the value of seed (line 10).
I was well aware of this that is why I used a variable instead of a fixed value inside line 25.
The idea was to use the last byte read as the next "seed" but I didn't pursue it any further. "seed" must always
have a value greater than or equal to 1 and less than or equal to decimal value 256 added to the current byte in use.
(I assumed you guys would see the flaw and correct as you need.)
However if the current byte value would be zero then "seed" would have to be a minimum value of "1".
(This is taken care of with the limitation of fixing "seed" in the script shown.)
Not because of anything to do with binary zero in shell scripting per-se but it would just stop there until the
loop finished and give that character value at that point continuously ( <- if that sentence is lucid enough. ).

Bazza...

EDIT: Made more lucid.

This is a simple way of making it a little better without the complexity of storing the previous and current
bytes read. (Line 26.)
Code:
if [ $subscript -ge $file_size ]; then subscript=$[ ( $dec_value + 9999 ) ]; fi


Last edited by wisecracker; 09-21-2013 at 06:27 PM.. Reason: Rewrite to make more lucid...
 

9 More Discussions You Might Find Interesting

1. Solaris

Does Solaris have a random number generator?

I am trying to find a way to generate random numbers within a shell script. Does Solaris have a utility that will generate random numbers? Thanks in advance. B (3 Replies)
Discussion started by: one_ring99
3 Replies

2. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

3. Shell Programming and Scripting

Random Sentence Generator

Hi, I need to create a table with random sentences. I need lines that are upto 1000 characters in lenght. I need a random sentence generator that will create sentences and output it to a text file. The sentences should be of lenght varying from 1 to 1000. Does anyone know how this can be... (7 Replies)
Discussion started by: kaushys
7 Replies

4. Shell Programming and Scripting

Need specialized random string generator script

Hi, I need a script that will generate a set of random strings in sequence, with the ability to predetermine the length, quantity, and alphabet of individual string, and to use the outputs of earlier strings in the sequence to define the parameters of later strings. For examples, I might want... (5 Replies)
Discussion started by: vajrajames
5 Replies

5. Shell Programming and Scripting

Grab exactly one byte from a FIFO, at random intervals

I want to develop a script of the following form: #!/bin/bash # Function 'listen' opens a data stream # which stores all incoming bytes in # a buffer, preparing them to be # grabbed by a following function # which appears at random # intervals during the execution of # the script ... (11 Replies)
Discussion started by: vomv1988
11 Replies

6. Shell Programming and Scripting

A Crude 1KHz Audio Sinewave Generator Demo...

A very simple crude sinewave generator. The file required is generated inside the code, is linear interpolated and requires /dev/audio to work. Ensure you have this device, if not the download oss-compat from your OS's repository... It lasts for about 8 seconds before exiting and saves a... (5 Replies)
Discussion started by: wisecracker
5 Replies

7. UNIX for Dummies Questions & Answers

Changing a special line and Byte in a random file

Hello I created 3 files by: dd if=/dev/urandom bs=1024 count=1000000 of=./testfile1 dd if=/dev/urandom bs=1024 count=5000000 of=./testfile2 dd if=/dev/urandom bs=1024 count=10000000 of=./testfile3 Now I want to know how to make a change in a specific byte and/or line of theses files? (2 Replies)
Discussion started by: frhling
2 Replies

8. Shell Programming and Scripting

awk (or) UNIX random RGB colors generator?

Dear UNIX Friends, I was wondering if there is a random RGB color generator or any function in any unix platforms. Please share your ideas. Thanks (2 Replies)
Discussion started by: jacobs.smith
2 Replies

9. Shell Programming and Scripting

Random Password generator with 2 digits and 6 characters

I am using the below to random generate a password but I need to have 2 numeric characters and 6 alphabetic chars head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8 ; echo '' 6USUvqRB ------ Post updated at 04:43 PM ------ Any Help folks - Can the output be passed onto a sed command to... (9 Replies)
Discussion started by: infernalhell
9 Replies
random(7D)							      Devices								random(7D)

NAME
random, urandom - Strong random number generator device SYNOPSIS
/dev/random /dev/urandom DESCRIPTION
The /dev/random and /dev/urandom files are special files that are a source for random bytes generated by the kernel random number generator device. The /dev/random and /dev/urandom files are suitable for applications requiring high quality random numbers for cryptographic pur- poses. The generator device produces random numbers from data and devices available to the kernel and estimates the amount of randomness (or "entropy") collected from these sources. The entropy level determines the amount of high quality random numbers that are produced at a given time. Applications retrieve random bytes by reading /dev/random or /dev/urandom. The /dev/random interface returns random bytes only when suffi- cient amount of entropy has been collected. If there is no entropy to produce the requested number of bytes, /dev/random blocks until more entropy can be obtained. Non-blocking I/O mode can be used to disable the blocking behavior. The /dev/random interface also supports poll(2). Note that using poll(2) will not increase the speed at which random numbers can be read. Bytes retrieved from /dev/random provide the highest quality random numbers produced by the generator, and can be used to generate long term keys and other high value keying material. The /dev/urandom interface returns bytes regardless of the amount of entropy available. It does not block on a read request due to lack of entropy. While bytes produced by the /dev/urandom interface are of lower quality than bytes produced by /dev/random, they are nonetheless suitable for less demanding and shorter term cryptographic uses such as short term session keys, paddings, and challenge strings. Data can be written to /dev/random and /dev/urandom. Data written to either special file is added to the generator's internal state. Data that is difficult to predict by other users may contribute randomness to the generator state and help improve the quality of future gener- ated random numbers. By default, write access is restricted to the super-user. An administrator may change the default read/write restriction by changing the permissions on the appropriate special files. /dev/random collects entropy from providers that are registered with the kernel-level cryptographic framework and implement random number generation routines. The cryptoadm(1M) utility allows an administrator to configure which providers will be used with /dev/random. ERRORS
EAGAIN O_NDELAY or O_NONBLOCK was set and no random bytes are available for reading from /dev/random. EINTR A signal was caught while reading and no data was transferred. ENOXIO open(2) request failed on /dev/random because no entropy provider is available. FILES
/dev/random /dev/urandom ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability | SUNWcsr | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
cryptoadm(1M), open(2), poll(2), attributes(5) NOTES
/dev/random can be configured to use only the hardware-based providers registered with the kernel-level cryptographic framework by dis- abling the software-based provider using cryptoadm(1M). You can also use cryptoadm(1M) to obtain the name of the software-based provider. Because no entropy is available, disabling all randomness providers causes read(2) and poll(2) on /dev/random to block indefinitely and results in a warning message being logged and displayed on the system console. However, read(2) and poll(2) on /dev/random continue to work in this case. An implementation of the /dev/random and /dev/urandom kernel-based random number generator first appeared in Linux 1.3.30. A /dev/random interface for Solaris first appeared as part of the CryptoRand implementation. SunOS 5.10 21 June 2004 random(7D)
All times are GMT -4. The time now is 02:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy