private static (int, Func <KeyedHashAlgorithm>) Dict(HmacTypes type) { return(type switch { HmacTypes.HmacMd5 => (128, () => new HMACMD5()), HmacTypes.HmacSha1 => (160, () => new HMACSHA1()), HmacTypes.HmacSha256 => (256, () => new HMACSHA256()), HmacTypes.HmacSha384 => (384, () => new HMACSHA384()), HmacTypes.HmacSha512 => (512, () => new HMACSHA512()), _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) });
public static IHMAC Create(HmacTypes type, byte[] key) => Factory.Create(type, key);
public static IHMAC Create(HmacTypes type, string key, Encoding encoding = null) => Factory.Create(type, key, encoding);
internal HmacFunction(HmacTypes type, byte[] key) { _hmacConfig = HmacTable.Map(type); HashType = type; Key = key; }
public static IHMAC Create(HmacTypes type, byte[] key) => new HmacFunction(type, key);
public static IHMAC Create(HmacTypes type, string key, Encoding encoding = null) => new HmacFunction(type, encoding.SafeEncodingValue().GetBytes(key));