0

我离加密\解密还很远,但最近我遇到了这样的问题:

{"et":"sP8C8QnNiLWk9+dcE9jzHeN+vp28pXq2gB//HancFfB91UxTf6CK4ZCkGobrYkw5","iv":"+++i46W4eYQGYpEP","sb":"N9T1se0OxKX+Ze8q"}

这里应该是示例加密密码或短语,已知它是使用 WebCrypto 加密的。但是所有解密示例都将短语表示为 base64,将 salt/iv 表示为十六进制。可能存在以正确方式将其转换为十六进制的函数,或者可能没有办法用上面的数据解密这个?

4

1 回答 1

1

Base64 and Hex are just different ways of representing raw bytes of data. They are trivially converted between. For example, the IV is currently in Base64. If you wan to convert that to Hex, on most unix-like systems you can use base64 and xxd:

$ echo +++i46W4eYQGYpEP | base64 -D | xxd -p
fbefa2e3a5b879840662910f

That said, I'm not familiar with this particular format. Most encryption formats are ad hoc and don't follow any particular standard. In order to build a decryptor, you need to know the precise implementation details of the encryptor. Just looking around for "AES decryptor example" will not help you much here. Besides obviously needing to know the key, you need to know the algorithm, the mode, the padding scheme, and several other considerations if a salt is involved (I'm not clear what "sb" is here).

"Encrypted with WebCrypto" is not sufficient information. The first, most obvious question is: what is the encryption key? If you don't have that, then no, this is not decryptable. Once you have the key, you should get the code that generated this output, and write a decryptor that does each step in reverse.

于 2020-09-23T21:48:15.297 回答