信息安全,密码学Cryptography,rail fence cipher加密明文”welcome to computer science,秘钥长度4顺序4213

信息安全,密码学,rail fence cipher加密明文,秘钥长度4,顺序为4213
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- 喝茶看狗 2022-10-18 20:45关注
import re def Encipher(plaintext, keyLength, order): result_str = '' plaintext = plaintext.replace(" ", "") text_list = re.findall(r'.{%s}' % keyLength, plaintext) index = [i for i in range(keyLength)] index = sorted(index, key=lambda item: order[item]) for i in range(keyLength): for text in text_list: result_str += text[index[i]] return result_str if __name__ == '__main__': plaintext = input('plase input plaintext: ') keyLength = int(input('plase input keyLength: ')) order = input('plase input order: ') ciphertext = Encipher(plaintext, keyLength, order) print('ciphertext =', ciphertext)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报