首页 > 解决方案 > 加密字符串

问题描述

有一个程序可以加密任何值。问题是,我无法理解算法是什么。所以,例如

输入是1,输出是cwjtCNNxuYsB+fns/5h66g==

输入是2,输出是UR/EJ8GNC/eG5zFXBwbXDw==等等。

当输入变大时,输出也变大:

输入London is the capital of Great Britain,输出mnmxU29GVF+e+zn6Y8k246TdbF3wafzl7/ohdgA9KEvZNoLG02JW5HdcwZJNiZmA

这里奇怪的是这些“+”、“/”和“=”。

我不明白如何对这种密码进行分类。

标签: encryptioncryptography

解决方案


That output (with the "+", "/" and "=") is base64 encoding.

Base64 is an encoding standard that uses a number of ASCII characters to represent binary data, by translating it into a radix-64 representation.

It's widely used to make messages that are encrypted easy to transport over email, WhatsApp, iMessage, etc.

Looking at your examples, they also seem to be encrypted, however, all ciphers will produce larger and larger ciphertext as plaintext input increases.

I expect this is some type of symmetric block cipher.

AES - the Advanced Encryption Standard, has a block size of 128-bits. Ergo, no matter how small the input (even 1 bit) it will be padded to at least 128-bits. Given that your inputs of '1' and '-2' are in fact encrypted to a 128-bit output, I expect this is likely AES.

Indeed "London is the capital of Great Britain" is also a multiple of 128-bits, at 384-bit's of ciphertext.

mnmxU29GVF+e+zn6Y8k246TdbF3wafzl7/ohdgA9KEvZNoLG02JW5HdcwZJNiZmA ->

100110100111100110110001010100110110111101000110010101000101111110011110111110110011100111111010011000111100100100110110111000111010010011011101011011000101110111110000011010011111110011100101111011111111101000100001011101100000000000111101001010000100101111011001001101101000001011000110110100110110001001010110111001000111011101011100110000011001001001001101100010011001100110000000 == 384-bits/128-bit block size = 3 Blocks of data.


推荐阅读