| Name | Random Hash Generator |
| Version | v2.0.0 |
| DockerHub | beetaone/random-hash-generator |
| Authors | Marcus Jones |
This module and project demonstrates a docker container reading data from a device (/dev/random), processing it (hashing) and sending it to the next module.
| Environment Variables | type | Description |
|---|---|---|
| HASH | string | Hash function |
| INTERVAL | string | Sleep interval in seconds |
| LABEL | string | JSON key for the output hash. |
| Environment Variables | type | Description |
|---|---|---|
| MODULE_NAME | string | Name of the module |
| MODULE_TYPE | string | Type of the module (Input, Processing, Output) |
| EGRESS_URLS | string | HTTP ReST endpoint for the next module |
The simple ingress module mounts the linux random device to generate and forward a random hash string.
The /dev/urandom device node in linux generates unlimited random bytes of data. The data is generated from the entropy pool.
Bytes can be collected in various ways, just as from any file;
The dd utility can read and convert data from a file. The following command would read 3 bytes of data.
random="$(dd if=/dev/urandom bs=3 count=1)"
The head utility can read lines of a file. The following command would read 4096 bytes of data.
random=$(head -n 4096 /dev/urandom)
The sha256sum utility hashes input. The utility outputs a - characture which can be cut for a clean output.
echo My data | sha256sum | cut -f 1 -d " "
The jq utility can be used to package data into a JSON structure. The following command would place a variable $randomstring into the key value pair.
JSON_STRING=$( jq -n -r --arg hs "$randomstring" '{"random hash": $hs}' )
The curl utility is used to send HTTP data as a POST request. To avoid escaping newline and space characters, the payload (-d) is piped in.
echo $JSON_STRING | curl -d @- -H "Content-Type: application/json" -X POST http://url:port
Content type
Image
Digest
sha256:f4c87608a…
Size
6.8 MB
Last updated
almost 2 years ago
docker pull beetaone/random-hash-generator:v2.0.0