示例#1
0
		/// <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);
		}
示例#2
0
		/// <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);
		}