Exemple #1
0
        public static bool VerifySignature(string signatureFilePath, int keySize, string publicKeyFilePath)
        {
            var signatureText      = FileOperations.ReadFromTextFile(signatureFilePath);
            var signatureTextSplit = signatureText.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);

            var signature = Converter.HexStringToBytes(signatureTextSplit[1]);
            var message   = Converter.HexStringToBytes(signatureTextSplit[3]);

            return(RSA.VerifyData(message, keySize, publicKeyFilePath, new SHA1CryptoServiceProvider(), signature));
        }
Exemple #2
0
        public static void CreateEnvelopeSignature(string envelopeTextFilePath, int keySize, string privateKeyFilePath,
                                                   string outputFilePath)
        {
            var message      = FileOperations.ReadFromTextFile(envelopeTextFilePath);
            var messageBytes = FileOperations.ReadFromBinaryFile(envelopeTextFilePath);
            var signature    = RSA.SignData(messageBytes, keySize, privateKeyFilePath, new SHA1CryptoServiceProvider());

            var hashText = Converter.ByteArrayToString(signature);

            var digitalSignature = "Signature:" + Environment.NewLine + hashText + Environment.NewLine +
                                   Environment.NewLine + "Message:" + Environment.NewLine + message;

            FileOperations.WriteToTextFile(outputFilePath, digitalSignature);
        }