예제 #1
0
파일: QuickExt.cs 프로젝트: xuhaoa/WinPIT
        public static string GetHash(byte[] toGetHashFrom, HashType hType)
        {
            byte[] hashed    = null;
            var    hashedHex = string.Empty;

            switch (hType)
            {
            case HashType.MD5:
                hashed    = new MD5CryptoServiceProvider().ComputeHash(toGetHashFrom);
                hashedHex = hashed.GetHex();
                break;

            case HashType.RIPEMD160:
                hashed    = new RIPEMD160Managed().ComputeHash(toGetHashFrom);
                hashedHex = hashed.GetHex();
                break;

            case HashType.SHA1:
                hashed    = new SHA1CryptoServiceProvider().ComputeHash(toGetHashFrom);
                hashedHex = hashed.GetHex();
                break;

            case HashType.SHA256:
                hashed    = new SHA256CryptoServiceProvider().ComputeHash(toGetHashFrom);
                hashedHex = hashed.GetHex();
                break;

            case HashType.SHA384:
                hashed    = new SHA384CryptoServiceProvider().ComputeHash(toGetHashFrom);
                hashedHex = hashed.GetHex();
                break;

            case HashType.SHA512:
                hashed    = new SHA512CryptoServiceProvider().ComputeHash(toGetHashFrom);
                hashedHex = hashed.GetHex();
                break;
            }

            return(hashedHex);
        }