Question

I am trying to encrypt a plaintext string in RSA using phpseclib0.3.5.

My problem is I am trying to get rid of random padding and make it so I can manually set it. I know this is bad for security reasons, but it must be done. We are conducting a password study, and do not want to store the private key on the server. We will just be encrypting with the public key and comparing ciphertexts to test a login. Therefore, for the same plaintext, the ciphertexts must be the same everytime they are generated.

Hopefully somebody knows how to do this. I have been trying to sift through the phpseclib code but it is not friendly.

Thanks

Was it helpful?

Solution

I think you are using the wrong tools. If you want to use comparison to check if the right password is given, you should use hash functions like SHA-2 instead of public key encryption. You can do the latter in addition if for some reason you need to recover the passwords (usually a bad idea in production, but maybe useful for your setting)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top