The data to be decrypted exceeds the maximum for this modulus of 36 bytes

前端 未结 2 939
时光说笑
时光说笑 2021-01-22 18:51

I\'m trying to make a password safe, but theres something wrong with how I use RSA. Heres my codes:

    private void testencodedecode()
    {
        string mehd         


        
2条回答
  •  再見小時候
    2021-01-22 19:44

    The modulus for RSA should be at least 1024 bits (128 bytes). Anything less will be completely insecure. And for modern applications it is even recommended to use a 2048 or larger modulus.

    And secondly, you are not generating the RSA keys properly! You shouldn't just use the password as a modulus..

    The public exponent and the modulus must be chosen such that the exponent is relatively prime to p-1 for all primes p which divide the modulus. If you are just arbitrarily setting the modulus to a binary representation of a password (PWDKEY) it's unlikely that you are choosing an appropriate exponent/modulus pair. And as I said earlier the modulus must be a relatively large number, usually chosen to be 1024, 2048 or 4096 bits long.

提交回复
热议问题