The implementation is as shown in the following:
[Email protected] shell]# bash zong.sh
================== Caesar encryption and decryption ==============================
1) input string for Caesar encryption (the input string can only be letters, numbers, spaces)
2) decrypted with encrypted string
3) exit
Input:q
The shell code is as follows:
#!/bin/bashjiami () { echo {a: Z} | xargs -n1 >file echo {a. Z} {a. z} @ @ | xargs -n1 >>file read -p "Input:" num num1= ' echo $num |sed ' s/ /@/g ' | tr ' 0-9 ' ' a-j ' a=${#num1} for i in ' seq $a ' do q= ' echo $num 1 | cut -c $i ' w= ' Cat -n file | awk '/' $q '/' | head -1|awk ' {print $1} ' w=$ (($w + 1)) d= ' cat file | sed -n ' $w ' P ' echo -n "$d" done Echo}jiemi () { echo {a: Z} | xargs -n1 >file echo {a. Z} {a. Z} {a. z} @ @ | xargs -n1 >>file read -p "Input:" num num1= ' echo $num | sed ' s/@/@/g ' &NBSP;&NBSP;&Nbsp; a=${#num1} for i in ' seq $a ' do q= ' echo $num 1 | cut -c $i ' w= ' cat - n file | awk '/' $q '/' | tail -1|awk ' {print $1} ' w=$ (($w-1)) d= ' cat file | sed -n ' $w ' P ' v= ' echo -n ' $d ' echo -n $v | sed ' s/@/ /g ' | tr ' a-j ' ' 0-9 ' done echo}together () {case $choice in 1) jiami ;; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;2) jiemi ;; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;3) exit 0 ;; *) exit 0 ;; esac}while :d ocat << eof================== Caesar encryption and decryption ============================== 1) input string for Caesar encryption (the input string can only be letters, numbers, spaces) &NBSP;&NBSP;&NBSP;2) The encrypted string is decrypted 3) exit eof read -p "INPUT:" choice together echodone
The implementation results are as follows:
================== Caesar encryption and decryption ==============================
1) input string for Caesar encryption (the input string can only be letters, numbers, spaces)
2) decrypted with encrypted string
3) exit
Input:1
Input:a 123b
[Email protected]
================== Caesar encryption and decryption ==============================
1) input string for Caesar encryption (the input string can only be letters, numbers, spaces)
2) decrypted with encrypted string
3) exit
Input:2
Input:[email protected]
A 123b
This article is from the "It Life" blog, so be sure to keep this source http://dingxue.blog.51cto.com/12290895/1972182
Shell finishing (38) = = = Caesar encryption and decryption