Algorithme de hachage: Utilisation de la méthode ‘create(SHA1″)’ sur un Stream »

Author:

Exemple,d'utilisation,de,'PermissionSet'
Download

using System;
using System.IO;
using System.Security.Cryptography;
 
class ExHashAlgorithm {
    public static void Main(string[] args)
    {
        using (HashAlgorithm AlgHash = HashAlgorithm.Create("SHA1"))
        {
            using (Stream fichier = new FileStream(@"c:test.txt", FileMode.Open, FileAccess.Read))
            {
                byte[] hash = AlgHash.ComputeHash(fichier);
 
                Console.WriteLine(BitConverter.ToString(hash));
            }
        }
    }
}