Esempio n. 1
0
        /// <summary>
        /// 复制构造函数
        /// </summary>
        /// <param name="t"></param>
        public SM3(SM3 t)
        {
            XBuf = new byte[t.XBuf.Length];
            Array.Copy(t.XBuf, 0, XBuf, 0, t.XBuf.Length);

            XBufOff   = t.XBufOff;
            ByteCount = t.ByteCount;
        }
Esempio n. 2
0
        /// <summary>
        /// 获取SM3值
        /// </summary>
        /// <param name="str">需要加密的字符串</param>
        /// <returns>加密后的字符串</returns>
        public static string SM3Encrypt(string str)
        {
            var sm3    = new Crypto.SM3();
            var buffer = System.Text.Encoding.UTF8.GetBytes(str);

            sm3.BlockUpdate(buffer, 0, buffer.Length);
            buffer = sm3.DoFinal();
            return(cvt.BytesToHexString(buffer));
        }