Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions utils/base32
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

usage () {
echo "This is a replacement for base32 (from GNU coreutils), which is not easily available on ci-centos machines.

Usage:
pipe content to be encoded into this executable, or pipe content with -d to decode.

Examples:
echo 'some string that I used to know' | $0 # ONXW2ZJAON2HE2LOM4QHI2DBOQQESIDVONSWIIDUN4QGW3TPO4======
echo 'ONXW2ZJAON2HE2LOM4QHI2DBOQQESIDVONSWIIDUN4QGW3TPO4======' | $0 -d # some string that I used to know
"
exit
}

DECODE=0
for i in "$@"
do
case $i in
-d) DECODE=1; shift;;
--help|--version) usage; shift;;
esac
done

read -t 60 TEXT

if [ $DECODE -eq 1 ];then
python3 -c "import base64; print(base64.b32decode(bytearray('$TEXT', 'ascii')).decode('utf-8'))"
else
python3 -c "import base64; print(base64.b32encode(bytearray('$TEXT', 'ascii')).decode('utf-8'))"
fi