Exemplo n.º 1
0
        /// <summary>
        /// Obtains a file's hash using the specified hash
        /// </summary>
        /// <param name="path">The location of the file required to be hashed</param>
        /// <param name="hashWanted">The hash alogorithm required</param>
        /// <returns>Hash of the file</returns>
        public static string GetFileHash(string path, string hashWanted)
        {
            HashService hashService = HashServiceFactory.Create(hashWanted);
            string      hash;

            using (FileStream fileStream = File.OpenRead(path))
            {
                hash = hashService.ToHex(hashService.ComputeHash(fileStream));
            }
            return(hash);
        }
Exemplo n.º 2
0
        public static string GetFileHash(byte[] bytes)
        {
            HashService hashService = HashServiceFactory.Create(UserSettings.Load().Hash);

            return(hashService.ToHex(hashService.ComputeHash(bytes)));
        }