encrypt 548 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. export PATH=/bin:/usr/bin
  3. if [ ! -e /usr/bin/openssl ]; then
  4. echo $0: requires /usr/bin/openssl, please install openssl tools
  5. exit 1
  6. fi
  7. if [ "$#" -lt 1 ]; then
  8. echo $0: Usage: $0 '<input>' '[output]'
  9. exit 1
  10. fi
  11. if [ ! -r "$1" ]; then
  12. echo $0: $1 does not exist or is not readable.
  13. exit 1
  14. fi
  15. outpath="$1.aes"
  16. if [ "$#" -ge 2 ]; then
  17. outpath="$2"
  18. fi
  19. if [ -f "$outpath" ]; then
  20. echo $0: $outpath already exists, delete or rename first.
  21. exit 1
  22. fi
  23. openssl aes-256-cbc -salt -in "$1" -out "$outpath"
  24. echo $0: wrote "$outpath"