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
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.