. NET has a wealth of encryption and decryption API library for our use, this blog summary. NET hash hash algorithm, and made into a simple demo, hope to be helpful to everyone.
MD5
Using System;
Using System.Collections.Generic;
Using System.Text;
Using System.Security.Cryptography;
Namespace Encryptanddecrypt
{public
class MD5
{public
byte[] Hash (byte[] data)
{
System.Security.Cryptography.MD5 MD5 = System.Security.Cryptography.MD5.Create ();
return Md5.computehash (data);}}
SHA1
Using System;
Using System.Collections.Generic;
Using System.Text;
Using System.Security.Cryptography;
Namespace Encryptanddecrypt
{public
class SHA1
{public
byte[] Hash (byte[] data)
{
System.Security.Cryptography.SHA1 SHA1 = System.Security.Cryptography.SHA1.Create ();
return Sha1.computehash (data);}}
SHA256
Using System;
Using System.Collections.Generic;
Using System.Text;
Using System.Security.Cryptography;
Namespace Encryptanddecrypt
{public
class SHA256
{public
byte[] Hash (byte[] data)
{
System.Security.Cryptography.SHA256 sha256= System.Security.Cryptography.SHA256.Create ();
return Sha256.computehash (data);}}
SHA384
Using System;
Using System.Collections.Generic;
Using System.Text;
Using System.Security.Cryptography;
Namespace Encryptanddecrypt
{public
class SHA384
{public
byte[] Hash (byte[] data)
{
System.Security.Cryptography.SHA384 sha384 = System.Security.Cryptography.SHA384.Create ();
return Sha384.computehash (data);}}
SHA512
Using System;
Using System.Collections.Generic;
Using System.Text;
Using System.Security.Cryptography;
Namespace Encryptanddecrypt
{public
class SHA512
{public
byte[] Hash (byte[] data)
{
System.Security.Cryptography.SHA512 sha512 = System.Security.Cryptography.SHA512.Create ();
return Sha512.computehash (data);}}