/// <summary> /// Decrypt with private key /// </summary> /// <param name="data"></param> /// <param name="encryptionEncodeMode"><see cref="CryptoBase.DefaultEncryptionEncodeMode"/></param> /// <param name="privateKey">Private key</param> /// <returns></returns> public string Decrypt(string data, EncodeMode encryptionEncodeMode, string privateKey) { if (string.IsNullOrWhiteSpace(data)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(data)); } if (string.IsNullOrWhiteSpace(privateKey)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(privateKey)); } return(DefaultEncoding.GetString(Decrypt(encryptionEncodeMode.DecodeToBytes(data, DefaultEncoding), privateKey))); }
/// <summary> /// Verification with public key /// </summary> /// <param name="data"></param> /// <param name="signature"></param> /// <param name="signatureEncodeMode"><see cref="CryptoAndSignatureBase.DefaultSignatureEncodeMode"/></param> /// <param name="publicKey">Public key</param> /// <returns></returns> public bool VerifyData(string data, string signature, EncodeMode signatureEncodeMode, string publicKey) { if (string.IsNullOrWhiteSpace(data)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(data)); } if (string.IsNullOrWhiteSpace(signature)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(signature)); } if (string.IsNullOrWhiteSpace(publicKey)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(publicKey)); } return(VerifyData(DefaultEncoding.GetBytes(data), signatureEncodeMode.DecodeToBytes(signature, DefaultEncoding), publicKey)); }
public override byte[] GetBytesKey() { return(_keyEncodeMode.DecodeToBytes(_key, DefaultEncoding)); }