Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon committed Jul 11, 2022
1 parent b9e9fcc commit 34df4bc
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/actions/rng/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ name: "RNG"
description: "Generate random bytes using /dev/urandom. WARNING: only use for non-cryptographic purposes (the results will show in logs)."
inputs:
length:
description: "Length to generate (in bytes)."
required: true
description: "Number of raw random bytes to generate."
default: 16
required: false
outputs:
random:
description: "The output of the RNG (hex-encoded)."
description: >
The output of the RNG encoded in hexadecimal.
Note: Due to the encoding, the length of the string will be twice as long as the input length request by the user.
value: "${{ steps.prng.outputs.result }}"

runs:
Expand All @@ -19,7 +22,10 @@ runs:
run: |
set -euo pipefail
value=$(head -c"$LENGTH" /dev/urandom | xxd -p)
# Note: if we need to support different encoding, we can use
# `head -c"$LENGTH" /dev/urandom | xxd ...` instead.
# -l: the number of bytes
# -c: the number of bytes displayed per column
value=$(xxd -p -l "$LENGTH" -c "$LENGTH" /dev/urandom)
echo "::set-output name=result::$value"

0 comments on commit 34df4bc

Please sign in to comment.