1755652743

This commit is contained in:
2025-08-19 19:19:02 -06:00
parent 17f340d3a5
commit c16152b000
2 changed files with 9 additions and 4 deletions
+7 -3
View File
@@ -1,12 +1,14 @@
#!/bin/bash
# usage: randomtoken [bytes] [mode]
# defaults: bytes=16, mode=hex
# modes: hex, sha256, sha512, md5, base64, raw
# requires xxd
# handle args and defaults
if [ "$#" -ne 2 ]; then
bytes=16
mode=hex
echo "Usage: $0 [bytes] [mode]"
echo "Defaults: bytes=16, mode=hex"
echo "Modes: hex, md5, sha1, sha256, sha512, base64, raw"
exit 1
else
bytes=$1
mode=$2
@@ -17,6 +19,8 @@ if [ "$mode" = "sha256" ]; then
dd if=/dev/urandom bs=1 count=$bytes status=none | sha256sum | awk '{print $1}'
elif [ "$mode" = "sha512" ]; then
dd if=/dev/urandom bs=1 count=$bytes status=none | sha512sum | awk '{print $1}'
elif [ "$mode" = "sha1" ]; then
dd if=/dev/urandom bs=1 count=$bytes status=none | sha1sum | awk '{print $1}'
elif [ "$mode" = "md5" ]; then
dd if=/dev/urandom bs=1 count=$bytes status=none | md5sum | awk '{print $1}'
elif [ "$mode" = "base64" ]; then