Create cryptographic signature of less than 1024 bits
I need to sign a QR code and I tried using some standard .Net code to create a cryptographic signature:
开发者_JAVA技巧var privateKey = (RSACryptoServiceProvider) certificate.PrivateKey;
var data = Encoding.UTF8.GetBytes( payload );
var signature = privateKey.SignData( data, new SHA1Managed() );
This works but the signature is 1024 bits long - too much for the QR code I want to create.
Does anyone know if it's possible to generate a shorter signature, e.g. 512 bits?
Alternatively, is there a standard for signing QR codes?
The signature will be the same length as the modulus for the keys you are using. If you are not specifying the modulus when creating the certificate it will default to 1024 bits. You can change the length to 512 and then the resulting signature will be 512 bits.
To change the modulus when creating the certificate use the RSAParameters struct.
精彩评论