I know I’m going to forget how to do this in the future and it’s probably something I’ll re-use to help me generate 32 byte keys in the future.
To generate the random key use the following commands from Bash.
date +%s | sha256sum | head -c 64 ; echo
Then take the resulting string (we’ll call it secret), which will 64 hexadecimal characters long, and use it in the following Haskell list comprehension (I evaluate it with GHCi) to turn it into an array of properly formatted hexadecimal literals like so.
Prelude> import qualified Data.Text as T Prelude T> ["0x" ++ (T.unpack i) | i <- T.chunksOf 2 (T.pack "secret")]
Which will output something in the following format.
["0xHH", "0xHH", ...]