首页 > 其他 > 详细

南邮 n次base64

时间:2019-04-04 20:32:15      阅读:107      评论:0      收藏:0      [点我收藏+]

打开题目 提示很明显,也没有隐瞒

技术分享图片

难点是写python,网上题解

----------------------------------------------------------

# coding:utf8

import base64

def repeatedb64decode(ciphertext, times):
    ‘‘‘
    功能 : 
        指定次数解密Base64
    参数 : 
        ciphertext : 密文
        times : 次数
    返回 : 
        返回将密文解密times次得到的明文
    备注 : 
        当用户输入次数大于密文加密次数时候 , 只会解密到最终的明文 , 而不会一直进行解密
    ‘‘‘
    for i in range(times):
        try:
            ciphertext = base64.b64decode(ciphertext)
        except Exception:
            return ciphertext
    return ciphertext

def recursive64decode(ciphertext):
    ‘‘‘
    功能 : 
        递归解密Base64
    参数 : 
        ciphertext : 密文
    返回 : 
        返回彻底解密得到的明文
    ‘‘‘
    while True:
        try:
            ciphertext = base64.b64decode(ciphertext)
        except Exception:
            return ciphertext

def repeatedb64encode(plaintext , times):
    ‘‘‘
    功能 : 
        指定次数加密Base64
    参数 : 
        plaintext : 明文
        times : 密文
    返回 : 
        将plaintext加密times次得到的密文
    备注 : 
        加密不存在异常抛出的问题
    ‘‘‘
    for i in range(times):
        plaintext = base64.b64encode(plaintext)
    return plaintext

ciphertext = ""

print recursive64decode(ciphertext)
----------------------------------------------
参考 https://www.jianshu.com/p/7e3ce1338b2c

 

南邮 n次base64

原文:https://www.cnblogs.com/islsy/p/10656818.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!