public static void SignEachFile(string[] filePaths, string signatureFilePath, string comment, bool preHash, byte[] privateKey) { privateKey = PrivateKey.Decrypt(privateKey); if (privateKey == null) { return; } if (string.IsNullOrEmpty(comment)) { comment = _defaultComment; } foreach (string filePath in filePaths) { try { DigitalSignatures.SignFile(filePath, signatureFilePath, comment, preHash, privateKey); DisplayMessage.FilePathMessage(filePath, "File signed successfully."); } catch (Exception ex) when(ExceptionFilters.Cryptography(ex)) { DisplayMessage.FilePathException(filePath, ex.GetType().Name, "Unable to create signature."); } } CryptographicOperations.ZeroMemory(privateKey); }
public static void SignEachFile(byte[] privateKey, string comment, bool preHash, string[] filePaths) { privateKey = PrivateKey.Decrypt(privateKey); if (privateKey == null) { return; } if (string.IsNullOrEmpty(comment)) { comment = _defaultComment; } foreach (string filePath in filePaths) { try { DigitalSignatures.SignFile(filePath, comment, preHash, privateKey); DisplayMessage.FilePathMessage(filePath, "File signed successfully."); } catch (Exception ex) when(ExceptionFilters.Cryptography(ex)) { Logging.LogException(ex.ToString(), Logging.Severity.Error); DisplayMessage.FilePathException(filePath, ex.GetType().Name, "Unable to create signature."); } } Utilities.ZeroArray(privateKey); }