using System; using System.Security.Cryptography; class Example { static void Main() { SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider(); // Hash data using SHA1 algorithm byte[] hash = sha1.ComputeHash(Encoding.UTF8.GetBytes("Hello World")); // Clear the SHA1CryptoServiceProvider instance sha1.Clear(); // Display the hash value Console.WriteLine(BitConverter.ToString(hash)); } }
using System; using System.Security.Cryptography; class Example { static void Main() { SHA1 sha1 = SHA1.Create(); byte[] data = Encoding.UTF8.GetBytes("Hello World"); byte[] hash = sha1.ComputeHash(data); // Clear the SHA1CryptoServiceProvider instance ((SHA1CryptoServiceProvider)sha1).Clear(); // Display the hash value Console.WriteLine(BitConverter.ToString(hash)); } }In this example, we create an instance of the SHA1 class using the Create method and use it to hash the string "Hello World". Since the SHA1 class is an abstract class, we cast it to the SHA1CryptoServiceProvider class to call the Clear method.