shell

using rot13 and tr command for having an encrypted email address


I have read many tutorials on the internet about the usage of the 'tr' command. However, I am not able to understand how to encrypt an email address with a shell script shift the characters using rot13. Can any one give a link or an example?


Solution

  • Not sure exactly how you want to use this, but here's a basic example to get you started:

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

    To make it easier, you can alias the tr command in your .bashrc file thusly:

    alias rot13="tr 'A-Za-z' 'N-ZA-Mn-za-m'"
    

    Now you can just call:

    echo 'fooman@example.com' | rot13