public static string GenerateSignature(string dateTime, string subjectId) { SHA1Managed sha1 = new SHA1Managed(); UnicodeEncoding encoding = new UnicodeEncoding(); string signature = string.Empty; X509Certificate2 objGetCertificate = null; RSACryptoServiceProvider privateKey = null; byte[] dateTimeBytes = Encoding.UTF8.GetBytes(dateTime); byte[] dateTimeByteshash = sha1.ComputeHash(dateTimeBytes); byte[] subjectIdBytes = Encoding.UTF8.GetBytes(subjectId); byte[] subjectIdByteshash = sha1.ComputeHash(subjectIdBytes); try { objGetCertificate = GetCertificate(); privateKey = (RSACryptoServiceProvider)objGetCertificate.PrivateKey; privateKey.SignHash(dateTimeByteshash, CryptoConfig.MapNameToOID("SHA1")); byte[] signaturebytes= privateKey.SignHash(subjectIdByteshash, CryptoConfig.MapNameToOID("SHA1")); signature = Convert.ToBase64String(signaturebytes); } catch (Exception ex) { } finally { if (objGetCertificate != null) objGetCertificate.Reset(); if (privateKey != null) privateKey.Dispose(); } return signature;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)