开发者

decrypt a cipher -- RoR

开发者 https://www.devze.com 2023-02-08 10:20 出处:网络
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 de

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

精彩评论

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