Files
go-nkode/secure_bytes.sh
2024-10-02 11:42:33 -05:00

15 lines
508 B
Bash

#!/bin/bash
# Define the number of bytes you want to generate
num_bytes=16
# Use dd to read cryptographically secure bytes from /dev/urandom
# and convert them to integers using od
secure_bytes=$(dd if=/dev/urandom bs=1 count=$num_bytes 2>/dev/null | od -An -tu1)
# Remove leading/trailing spaces and replace spaces with commas
secure_bytes=$(echo $secure_bytes | sed 's/ /,/g')
# Output the result as a comma-separated list of integers
echo "Cryptographically secure bytes (as integers): $secure_bytes"