System.Security.Cryptography.SHA512Managed.Dispose C# (CSharp) Méthode

Dispose() protected final méthode

protected final Dispose ( bool disposing ) : void
disposing bool
Résultat void
        protected override sealed void Dispose(bool disposing)
        {
            _hashProvider.Dispose(disposing);
            base.Dispose(disposing);
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Retorna el hash en format string de l'string paràmetre
        /// </summary>
        /// <param name="textIn"> és el text del qual volem calcular el hash</param>
        /// <returns> retorna un string amb el hash resultat o null si hi ha error</returns>
        static string CalculaHash(string textIn)
        {
            try
            {
                // Convertim l'string a un array de bytes
                byte[] bytesIn = UTF8Encoding.UTF8.GetBytes(textIn);
                // Instanciar classe per fer hash
                SHA512Managed SHA512 = new SHA512Managed();
                // Calcular hash
                byte[] hashResult = SHA512.ComputeHash(bytesIn);

                // Si volem mostrar el hash per pantalla o guardar-lo en un arxiu de text
                // cal convertir-lo a un string

                String textOut = BitConverter.ToString(hashResult, 0);

                // Eliminem la classe instanciada
                SHA512.Dispose();
                return textOut;
            }
            catch (Exception)
            {
                Console.WriteLine("Error calculant el hash");
                Console.ReadKey(true);
                return null;
            }
        }
All Usage Examples Of System.Security.Cryptography.SHA512Managed::Dispose