encryption - 加密字符串
问题描述
有一个程序可以加密任何值。问题是,我无法理解算法是什么。所以,例如
输入是1
,输出是cwjtCNNxuYsB+fns/5h66g==
输入是2
,输出是UR/EJ8GNC/eG5zFXBwbXDw==
等等。
当输入变大时,输出也变大:
输入London is the capital of Great Britain
,输出mnmxU29GVF+e+zn6Y8k246TdbF3wafzl7/ohdgA9KEvZNoLG02JW5HdcwZJNiZmA
。
这里奇怪的是这些“+”、“/”和“=”。
我不明白如何对这种密码进行分类。
解决方案
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.
推荐阅读
- azure - “Get-AzApplicationGatewayAvailableSslOption”不在“az”命令组中
- javascript - 无法显示我从用户加载的图像
- angular - 是否可以同时使用 mat-select 和 mat-chips?
- azure - 在 Spring Boot 应用程序中使用 Azure KeyVault 获取数据库密码
- html - spring形式的class和cssClass属性有什么区别
- image - 如何将我的类别与使用 Google vision api 在图像中检测到的标签进行匹配?
- linux - htpasswd 正在被网络缓存
- java - 如果路由不存在,如何配置spring boot抛出404错误?
- r - 在r中导入excel文件
- sql - 检索前 12 条记录,同时在给定字段中保持相同的值