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?
Description. Applying ROT13 to a piece of text merely requires examining its alphabetic characters and replacing each one by the letter 13 places further along in the alphabet, wrapping back to the beginning if necessary, preserving case: a becomes n, B becomes O, and so forth, down to Z, which becomes M.
rot13 is a text scrambling method to prevent text from being accidentally read, such as the answer to a riddle or joke some might consider offensive. It works by shifting each character forward 13 times, so that A becomes N, B becomes O, etc.
`tr` command can be used with -c option to replace those characters with the second character that don't match with the first character value. In the following example, the `tr` command is used to search those characters in the string 'bash' that don't match with the character 'b' and replace them with 'a'.
Not sure exactly how you want to use this, but here's a basic example to get you started:
echo '[email protected]' | 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 '[email protected]' | rot13
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With