2015-04-05 08:24:24 +08:00
|
|
|
encode64() {
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
cat | base64
|
|
|
|
else
|
|
|
|
printf '%s' $1 | base64
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-11-07 03:50:39 +08:00
|
|
|
encodefile64() {
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
echo "You must provide a filename"
|
|
|
|
else
|
|
|
|
base64 -i $1 -o $1.txt
|
|
|
|
echo "${1}'s content encoded in base64 and saved as ${1}.txt"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-04-05 08:24:24 +08:00
|
|
|
decode64() {
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
cat | base64 --decode
|
|
|
|
else
|
|
|
|
printf '%s' $1 | base64 --decode
|
|
|
|
fi
|
|
|
|
}
|
2012-06-14 18:31:00 +08:00
|
|
|
alias e64=encode64
|
2022-11-07 03:50:39 +08:00
|
|
|
alias ef64=encodefile64
|
2012-06-14 18:31:00 +08:00
|
|
|
alias d64=decode64
|