Reputation: 133
I'm having trouble putting the contents of sha256sum from user input into a variable:
echo "Your password please"
read -e pass
pass256=${pass | sha256sum}
printf "Password SHA256 is "$pass256"\n\n"
exit
After execution the script says:
./password_hashing: line 12: ${pass | sha256sum}: bad substitution
I have tried to enclose the complete command between parentheses, without curly_brackets, between single quotes.
Upvotes: 0
Views: 295
Reputation: 15418
Try
pass256=$(sha256sum<<<"$pass")
or if you don't want the trailing *-
,
read pass256 _ <<< $(sha256sum<<<"$pass")
Upvotes: 1