Пример #1
0
        public static string SM3(string data)
        {
            data = ConvertTool.RemoveSpace(data);

            string res = "";
            SM3Cng sm3 = new SM3Cng();

            if (data.Contains(":"))
            {
                using (FileStream fs = new FileStream(data, FileMode.Open))
                {
                    res = ConvertTool.Bytes2String(sm3.ComputeHash(fs));
                }
            }
            else
            {
                //if (data.Length % 2 != 0)
                //    throw new Exception("Invalid Data, Not 2*n bytes");
                res = ConvertTool.Bytes2String(sm3.ComputeHash(ConvertTool.String2Bytes(data)));
            }

            return(res);
        }
Пример #2
0
 public SM3Cng(SM3Cng t)
 {
     Buffer.BlockCopy(t.xBuf, 0, this.xBuf, 0, t.xBuf.Length);
     this.xBufOff = t.xBufOff;
     Buffer.BlockCopy(t.V, 0, this.V, 0, t.V.Length);
 }