Esempio n. 1
0
        /// <summary>
        /// 使用 HMAC-MD5 演算法進行資料加密。
        /// </summary>
        /// <param name="s">原字串。</param>
        /// <param name="key">加密鍵值。</param>
        public static string HMACMD5Encrypt(string s, string key)
        {
            ASCIIEncoding oEncoding;

            byte[]  oKeyByte;
            byte[]  oMessageBytes;
            HMACMD5 oMD5;

            oEncoding     = new ASCIIEncoding();
            oKeyByte      = oEncoding.GetBytes(key);
            oMessageBytes = oEncoding.GetBytes(s);
            oMD5          = new HMACMD5(oKeyByte);
            return(BaseFunc.ByteToHex(oMD5.ComputeHash(oMessageBytes)));
        }