开发者

decrypt a cipher -- RoR

In my Rails App, I have a client 'C1' who will send me the username of C1's clients. I and C1 share a salt. C1 will send me the username encrypted with the help of the shared salt. Now I need to decrypt it and get the original username an开发者_开发技巧d store it in my dB. How can I do it?

Please help. Thanks in Advance.


You seem to be confused about cryptography in general.

The SHA's are Cryptographic Hash Functions. They are designed so as not to be reversible.

If you want secure communication between yourself and the client use a channel with end-to-end encryption, such as https.


If you are using SHA1 (or any other hashing algorithm), the solution is to generate the same hash on the server side and compare it with what was sent. If the resulting hash on the server side is the same as hash sent by the client it's likely the correct username.

In ruby Digest::SHA1.hexdigest would allow you to generate a SHA1 hash.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜