/** * Sign the message with the private key of the merchant. * * @param $message * @return mixed */ public string signMessage(object message) { string msg; if (message is List <string> ) { var t = message as List <string>; msg = string.Join("", t); } else { msg = message.ToString(); } RSA pkeyid = KeyReader.ReadPrivateKeyFromPKCS12(privateKey, privateKeyPassword); byte[] signature = pkeyid.SignData(Encoding.GetEncoding("windows-1251").GetBytes(msg), HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1); pkeyid.Dispose(); string temp = msg + Encoding.GetEncoding("windows-1251").GetString(signature); Debug.WriteLine(temp); return(temp); }
public RSA getCertificate() { return(KeyReader.ReadPublicKey(publicCertificate)); }