Shell finishing (38) = = = Caesar encryption and decryption

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.