Created
November 11, 2016 20:15
-
-
Save BennettSmith/20a98bfaa5b4f0797dfa66706f7765c3 to your computer and use it in GitHub Desktop.
Transform a text string into an sha256 hash and then base64 encode it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Takes in an e-mail address and answers back with the expected hash used | |
# for the AWS Cognito username field. | |
# | |
args=`getopt e: $*` | |
if [ $? != 0 ]; then | |
echo "Usage: ..." | |
exit 2 | |
fi | |
set -- $args | |
for i | |
do | |
case "$i" | |
in | |
-e) | |
earg="$2"; shift; | |
shift;; | |
esac | |
done | |
if [ "X$earg" == "X" ]; then | |
echo "Usage: ..." | |
exit 3 | |
else | |
echo -n $earg | shasum -a 256 | cut -d " " -f 1 | xxd -r -p | base64 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment