0
#!/bin/bash

    selection=
    until [ "$selection" = "0"]; do
     echo ""
     echo "PROGRAM MENU"
     echo "1 - Encrypt text with Rot13"
     echo "2 - DEcrypt text with Rot13"
     echo ""
     echo "0 - Exit program"
     echo ""
     echo -n "Enter Selection:"
     read selection
     echo ""
     case $selection in
         1 ) echo "Line to be encrypted"
         rot13 "a-z"
         2 ) echo "Line to be decrypted"
         rot13 "n-za-m"
         3 ) exit;;
         * ) echo "Please enter 1,2, or 0"
     esac
done

I want to read a .txt file, encrypt it, save it, and afterwards decrypt it.

4

1 回答 1

2

快速谷歌搜索“rot13 in bash”给出了这个:使用 rot13 和 tr 命令获得加密的电子邮件地址

简而言之:

echo 'fooman@example.com' | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'

这应该是 ROT13 fooman@example.com。从这里很容易添加菜单项,提供文件而不是管道,并将输出保存到文件中。通过快速搜索也可以轻松找到所有其他操作。

于 2013-10-18T00:03:09.950 回答