KeyedHashAlgorithm: Utilisation de la méthode ‘KeyedHashAlgorithm.Create(HMACSHA1″)’ sur un Stream”

Author:

Exemple,d'utilisation,de,'PermissionSet'
{filelink=17842}

using System;
using System.IO;
using System.Text;
using System.Security.Cryptography;
class ExKeyedHashAlgorithm
 {
    public static void Main(string[] args)
	{
        byte[] clé = Encoding.Unicode.GetBytes(@"Area = u03A0r^2");

        using (KeyedHashAlgorithm AlgoHash = KeyedHashAlgorithm.Create("HMACSHA1"))
		{
            AlgoHash.Key = clé;

            using (Stream fichier = new FileStream(@"c:teste.txt", FileMode.Open, FileAccess.Read))
			{
                byte[] hash = AlgoHash.ComputeHash(fichier);

                Console.WriteLine(BitConverter.ToString(hash));
            }
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *