Posts

Showing posts with the label .Net Framework

Symmetric Cryptography

Image
This is the simplest kind of Cryptography that involves only one secret key to encrypt and decrypt information . It is also known as “Secret Key Cryptography”. Both Sender and receiver should know the key to be able to communicate securely. For Example: if Mahesh & Shalini wants to communicate using symmetric-key cryptography then both would have to devise key and use it for every communication. So Now, Mahesh encrypts his message using shared key, sends encrypted message to Shalini , then Shalini uses the same key again decrypt message to read. To demonstration symmetric-key cryptography , I will use AES ( Advanced Encryption Standard ) & .Net Framework in-build library “ System.Security.Cryptograph ” Output:

Asymmetric Cryptography (Public Key Cryptography) - Part I

Asymmetric cryptography, also known as public key cryptography, it uses two distinct, yet related keys. One key, the Public Key, is used for encryption and the other, the Private Key, is for decryption. Let say Mahesh wants to send an encrypted message to Shalini , Mahesh will look for Shalini Public key and use it for encrypt the message before sending it. Then Shalini Can decrypt the message using her related private key. if Mahesh encrypts the message using his private key, then the message can be decrypted only using Shalini's public key, thus it will also authenticate Shalini . These encryption and decryption processes happen automatically hence no need to share the keys. Asymmetric cryptography is slower then symmetric cryptography Advantages: 1. Does not require to share key 2. Simple structure RSA is common asymmetric algorithm, I will use the same for this example. To demonstrate, I have used .Net framework in build library “System.Security.Cryptograph

SHA-256(Source Code in C# using .Net in-built Cryptography library) - Part II

.Net Framework provides in built support for various hash functions like MD-5, SHA-1, SHA-256 etc... ComputeHash method Computes the hash value to the specified byte array. Below are the overloaded methods to Compute Hash using SHA-256 class in System.Security.Cryptography  library public byte [] ComputeHash( byte [] buffer) public byte [] ComputeHash( Stream inputStream) public byte [] ComputeHash( byte [] buffer, int offset, int count)