encode64.plugin.zsh 513 B

12345678910111213141516171819202122232425262728
  1. encode64() {
  2. if [[ $# -eq 0 ]]; then
  3. cat | base64
  4. else
  5. printf '%s' $1 | base64
  6. fi
  7. }
  8. encodefile64() {
  9. if [[ $# -eq 0 ]]; then
  10. echo "You must provide a filename"
  11. else
  12. base64 -i $1 -o $1.txt
  13. echo "${1}'s content encoded in base64 and saved as ${1}.txt"
  14. fi
  15. }
  16. decode64() {
  17. if [[ $# -eq 0 ]]; then
  18. cat | base64 --decode
  19. else
  20. printf '%s' $1 | base64 --decode
  21. fi
  22. }
  23. alias e64=encode64
  24. alias ef64=encodefile64
  25. alias d64=decode64