How can I generate a signature with my existing private key? will the code below works?
string privateKeyString = File.ReadAllText("private.key"); TextReader priReader = new StringReader(privateKeyString) PemReader pemReader = new PemReader(priReader); var obj = pemReader.ReadObject(); var pri = obj as RsaPrivateCrtKeyParameters;
Sha256Digest digest = new Sha256Digest();
RsaDigestSigner signer = new RsaDigestSigner(digest); signer.Init(true, pri); byte[] sig = signer.GenerateSignature();
var signature = Convert.ToBase64String(sig);