题目:
dict:{0: 'J', 1: 'K', 2: 'L', 3: 'M', 4: 'N', 5: 'O', 6: 'x', 7: 'y', 8: 'U', 9: 'V', 10: 'z', 11: 'A', 12: 'B', 13: 'C', 14: 'D',
15: 'E', 16: 'F', 17: 'G', 18: 'H', 19: '7', 20: '8', 21: '9', 22: 'P', 23: 'Q', 24: 'I', 25: 'a', 26: 'b', 27: 'c', 28: 'd', 29: 'e',
30: 'f', 31: 'g', 32: 'h', 33: 'i', 34: 'j', 35: 'k', 36: 'l', 37: 'm', 38: 'W', 39: 'X', 40: 'Y', 41: 'Z', 42: '0', 43: '1', 44: '2',
45: '3', 46: '4', 47: '5', 48: '6', 49: 'R', 50: 'S', 51: 'T', 52: 'n', 53: 'o', 54: 'p', 55: 'q', 56: 'r', 57: 's', 58: 't', 59: 'u',
60: 'v', 61: 'w', 62: '+', 63: '/', 64: '='}chipertext:
FlZNfnF6Qol6e9w17WwQQoGYBQCgIkGTa9w3IQKw
底下一串说是密文,那就按上面的字典先还原成明文,还原完是一串数字
[16, 36, 41, 4, 30, 52, 16, 48, 23, 53, 36, 48, 29, 21, 61, 43, 19, 38, 61, 23, 23, 53, 17, 40, 12, 23, 13, 31, 24, 35, 17, 51, 25, 21, 61, 45, 24, 23, 1, 61]
不难想到用正确的base64码表转换为base64编码形式
QkpEe0QwX1kwdV9rTm9XX1RoMXNfYjRzZV9tYXB9
再进行一次解码即可得到结果
b'BJD{D0_Y0u_kNoW_Th1s_b4se_map}'
脚本如下:
# 定义字典
import base64
# Base64编码表
base64_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
char_to_num = {'J': 0, 'K': 1, 'L': 2, 'M': 3, 'N': 4, 'O': 5, 'x': 6, 'y': 7, 'U': 8, 'V': 9,'z': 10, 'A': 11, 'B': 12, 'C': 13, 'D': 14, 'E': 15, 'F': 16, 'G': 17, 'H': 18,'7': 19, '8': 20, '9': 21, 'P': 22, 'Q': 23, 'I': 24, 'a': 25, 'b': 26, 'c': 27,'d': 28, 'e': 29, 'f': 30, 'g': 31, 'h': 32, 'i': 33, 'j': 34, 'k': 35, 'l': 36,'m': 37, 'W': 38, 'X': 39, 'Y': 40, 'Z': 41, '0': 42, '1': 43, '2': 44, '3': 45,'4': 46, '5': 47, '6': 48, 'R': 49, 'S': 50, 'T': 51, 'n': 52, 'o': 53, 'p': 54,'q': 55, 'r': 56, 's': 57, 't': 58, 'u': 59, 'v': 60, 'w': 61, '+': 62, '/': 63,'=': 64
}# 密文
ciphertext = "FlZNfnF6Qol6e9w17WwQQoGYBQCgIkGTa9w3IQKw"# 将密文转换为数字
numeric_representation = [char_to_num[char] for char in ciphertext]# 输出转换结果
print(numeric_representation)# 将每个数字映射到Base64编码表中的字符
encoded_string = ''.join(base64_table[num] for num in numeric_representation)# 输出Base64编码字符串
print(encoded_string)# 将Base64编码字符串转换为字节
decoded_bytes = base64.b64decode(encoded_string)# 输出解码后的字节数据
print(decoded_bytes)