c# подписываем файл сертификатом,полученную сигнатуру записываем в файл

public static bool CertificateSign(string signFilePath, string dumpFilePath, RSACryptoServiceProvider rsaKey)
        {
            byte[] data = null;
            using (System.IO.FileStream _FileStream = new System.IO.FileStream(dumpFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            using (System.IO.BinaryReader _BinaryReader = new System.IO.BinaryReader(_FileStream))
            {

                long _TotalBytes = new System.IO.FileInfo(dumpFilePath).Length;
                data = _BinaryReader.ReadBytes((Int32)_TotalBytes);
            }

            byte[] signature = rsaKey.SignData(data, new SHA1CryptoServiceProvider());
            File.WriteAllBytes(signFilePath, signature);
            return false;
        }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.