Пример #1
0
        public byte[] Hash(HashType type, byte[] input)
        {
            switch (type)
            {
            case HashType.Md5Hash:
                Md5Hash md5 = new Md5Hash();
                return(md5.Hash(input));

            case HashType.Sha1Hash:
                Sha1Hash sha1 = new Sha1Hash();
                return(sha1.Hash(input));

            case HashType.Sha2Hash:
                Sha2Hash sha2 = new Sha2Hash();
                return(sha2.Hash(input));

            case HashType.Sha3Hash:
                Sha3Hash sha3 = new Sha3Hash();
                return(sha3.Hash(input));

            case HashType.Sha5Hash:
                Sha5Hash sha5 = new Sha5Hash();
                return(sha5.Hash(input));

            default:
                return(null);
            }
        }
Пример #2
0
        // hashing overloads for different inputs
        // string input, byte input, with and without password
        // needs to return byte or string depending on input
        // if string input => string output
        // if byte input => byte output
        public string Hash(HashType type, string input)
        {
            switch (type)
            {
            case HashType.Md5Hash:
                Md5Hash md5 = new Md5Hash();
                return(md5.Hash(input));

            case HashType.Sha1Hash:
                Sha1Hash sha1 = new Sha1Hash();
                return(sha1.Hash(input));

            case HashType.Sha2Hash:
                Sha2Hash sha2 = new Sha2Hash();
                return(sha2.Hash(input));

            case HashType.Sha3Hash:
                Sha3Hash sha3 = new Sha3Hash();
                return(sha3.Hash(input));

            case HashType.Sha5Hash:
                Sha5Hash sha5 = new Sha5Hash();
                return(sha5.Hash(input));

            default:
                return("Cannot hash with this input");
            }
        }