我正在尝试使用 SecureBlackBox PGP 对文本文件进行数字签名。在执行以下代码时,我收到了签名失败的错误。
TElPGPKeyring keyring = new TElPGPKeyring();
var keyPath = @"C:\Keys\";
keyring.Load(keyPath + "0x894BE39C-pub.pkr",keyPath + "0xF36A0145.asc", true);
TElPGPKeyring secKeyring = new TElPGPKeyring();
secKeyring.AddSecretKey(keyring.get_SecretKeys(keyring.FindSecretKeyByEmailAddress("Testemail@gmail.com", 0)));
TElPGPWriter pgpWriter = new TElPGPWriter();
pgpWriter.SigningKeys = secKeyring;
keyring.get_SecretKeys(0).Passphrase = "Testphrase";
pgpWriter.Filename = "TestFile";
pgpWriter.Timestamp = DateTime.UtcNow;
pgpWriter.HashAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_MD_SHA512;
try
{
pgpWriter.SignFile(@"C:\ACH.NACHA.10116138.txt", @"C:\ACH.NACHA.101161381.txt.pgp", true);
}
catch (Exception anyEx)
{
throw anyEx;
}
**Signing failed (secret key mismatch/passphrase not provided?)**
Stacktrace:
at SBPGP.TElPGPWriter.y(TElPGPCustomSecretKey )
at SBPGP.TElPGPWriter.CalculateSignatures()
at SBPGP.TElPGPWriter.Sign(Stream ASourceStream, Stream ADestStream, Boolean Detached, Int64 Count)
at SBPGP.TElPGPWriter.SignFile(String ASourceFile, String ADestFile, Boolean Detached)
at TestSignApp.Program.SignFile() in C:\Users\Program.cs:line 32