一、实验项目名称(实验题目):
换位加密法
二、实验目的与要求:
掌握换位加密法的原理和流程,熟悉布尔运算。
三、实验内容:
1、练习。
With paper and pencil, encrypt the following messages with the key 9 using the transposition cipher. The (s) parts mark a single space. The number of characters has been provided for your convenience.
1.Underneath(s)a(s)huge(s)oak(s)tree(s)there(s)was(s)of(s)swine(s)a(s)huge(s)company, (61 characters)
2.That(s)grunted(s)as(s)they(s)crunched(s)the(s)mast:(s)(s)For(s)that(s)was(s)ripe,(s)and(s)fell(s)full(s)fast. (79 characters)
3.Then(s)they(s)trotted(s)away,(s)for(s)the(s)wind(s)grew(s)high:(s)(s)One(s)acorn(s)they(s)left,(s)and(s)no(s)more(s)might(s)you(s)spy. (96 characters)
Answers:
The (s) parts mark a single space:
1.Uhot(s)(s)on(s)ahoamdakef(s)pe(s)(s)r(s)harhtesunnur(s)wgyegewie,aeean(s)t(s)(s)sec
2.Tteestr(s)lheydthif(s)ad(s)(s):apeft(s)ct(s)tela(s)arh(s)(s),lsgsueFw(s)(s)tr(s)n(s)oaaf.utcmrsnunhha(s)(s)dl
3.T(s)a(s)(s)hc(s)d(s)uhtwtg:ol(s)m(s)erahr(s)renisnoyee(s)nfogp(s)t,(s)wO(s)t(s)hytt(s)w(s)nt,mt.hefiheh(s)o(s)edoni(s)earyy(s)rdgayneo
2、运行换位加密法加密程序。
# Transposition Cipher Encryption
# http://inventwithpython.com/hacking (BSD Licensed)
import pyperclip
def main():
myMessage = 'Common sense is not so common.'
myKey = 8
ciphertext = encryptMessage(myKey, myMessage)
# Print the encrypted string in ciphertext to the screen, with
# a | (called "pipe" character) after it in case