What's a good method/function to create a reversible hash?

南笙酒味 提交于 2019-12-13 15:51:59

问题


I need to transmit some data over the wire and I don't want that data being plain text.

The text I'm sending needs to be reversed so I can't md5/sha256/etc...

What's a good way to encode a salted string?


回答1:


You're looking for encryption.

What language are you using? You probably have a built-in encryption algorithm you can use.


The idea with hashing is that you can only go one-way.

[plain text]--->(HASH ALGORITHM)--->HASH


Whereas the idea with encryption is that you can use a key together with some plaintext to create a ciphertext. Then you can use the key on the ciphertext to retrieve the plaintext at any time:

[plain text] + [key] --->(ENCRYPTION ALGORITHM)-->[ciphertext]
[ciphertext] + [key] --->(DECRYPTION ALGORITHM)-->[plain text]

The decryption algorithm for a given encryption algorithm is usually very similar to the encryption algorithm, and it allows for the retrieval of a plaintext message given a ciphertext and the correct key (ie password).




回答2:


You want to use an encryption function, not a hash - which by definition is one-way.

The AES encryption algorithm would be a good start, as the is probably the most widely used one at present.




回答3:


You don't want a hash, you want encryption. You should look at Blowfish.



来源:https://stackoverflow.com/questions/2597047/whats-a-good-method-function-to-create-a-reversible-hash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!