public static Mac GetInstance (string name) { Mac m = new Mac (); switch (name.ToUpper ()) { case "HMACMD5": m.mac = new HMACMD5 (); break; case "HMACSHA1": m.mac = new HMACSHA1 (); break; } if (m.mac == null) throw new NotSupportedException (); return m; }
/// <exception cref="System.Exception"></exception> public virtual void Init(byte[] key) { if (key.Length > 20) { byte[] tmp = new byte[20]; System.Array.Copy(key, 0, tmp, 0, 20); key = tmp; } SecretKeySpec skey = new SecretKeySpec(key, "HmacSHA1"); mac = Mac.GetInstance("HmacSHA1"); mac.Init(skey); }
/// <exception cref="System.Exception"></exception> public virtual void Init(byte[] key) { if (key.Length > BSIZE) { byte[] tmp = new byte[BSIZE]; System.Array.Copy(key, 0, tmp, 0, BSIZE); key = tmp; } SecretKeySpec skey = new SecretKeySpec(key, "HmacMD5"); mac = Mac.GetInstance("HmacMD5"); mac.Init(skey); }
public static Mac GetInstance(string name) { Mac m = new Mac(); switch (name.ToUpper()) { case "HMACMD5": m.mac = new HMACMD5(); break; case "HMACSHA1": m.mac = new HMACSHA1(); break; } if (m.mac == null) { throw new NotSupportedException(); } return(m); }