【Python|密码学】换位加密法实验报告

本文介绍了换位加密法的原理和流程,通过实例展示了如何使用Python进行加密和解密操作。同时,文章探讨了布尔运算和变量作用域,并提供了多个关于列表、字符串操作及数学函数的练习题,旨在加深对Python编程的理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、实验项目名称(实验题目):
换位加密法
二、实验目的与要求:
掌握换位加密法的原理和流程,熟悉布尔运算。
三、实验内容:
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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值