Fuzz Base64 and Base64URL (#4853)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>pull/4862/head^2
parent
e86bb45477
commit
6b30d2d8de
@ -1 +1 @@ |
||||
Subproject commit c2236853aadb8e2d9909bbecdc490099519b70a4 |
||||
Subproject commit ae570fec082bfe1c1f45b0acca4a2b4f84d345ce |
@ -1,31 +0,0 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
set -euo pipefail |
||||
|
||||
_encode() { |
||||
# - Print the input to stdout |
||||
# - Remove the first two characters |
||||
# - Convert from hex to binary |
||||
# - Convert from binary to base64 |
||||
# - Remove newlines from `base64` output |
||||
echo -n "$1" | cut -c 3- | xxd -r -p | base64 | tr -d \\n |
||||
} |
||||
|
||||
encode() { |
||||
# - Convert from base64 to hex |
||||
# - Remove newlines from `xxd` output |
||||
_encode "$1" | xxd -p | tr -d \\n |
||||
} |
||||
|
||||
encodeURL() { |
||||
# - Remove padding from `base64` output |
||||
# - Replace `+` with `-` |
||||
# - Replace `/` with `_` |
||||
# - Convert from base64 to hex |
||||
# - Remove newlines from `xxd` output |
||||
_encode "$1" | sed 's/=//g' | sed 's/+/-/g' | sed 's/\//_/g' | xxd -p | tr -d \\n |
||||
} |
||||
|
||||
# $1: function name |
||||
# $2: input |
||||
$1 $2 |
Loading…
Reference in new issue