Skip to main content

Posts

Showing posts with the label Security

How to encrypt Bitmap image in c#

In this post I will show you how to encrypt bitmap image in c#.The technique is very simple.First we extract header from the image and then encrypt the rest byte data and then combined the header with this encrypted data.


using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace Enc { class Program { staticstring FILENAME = @"D:\ub.bmp"; staticstring ENCFILENAME = @"D:\enc.bmp"; staticvoid Main(string[] args) { //Create instance of DES TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); //Generate IV and Key des.GenerateIV(); des.GenerateKey(); //Set Encryption mode des.Mode = CipherMode.ECB; //Read FileStream fileStream = new FileStream(FILENAME, FileMode.Open, FileAccess.Read…

How to encrypt/decrypt data in asp.net using Symmetric algorithm

In this post I am going to show you how to encrypt and decrypt data in asp.net using Symmetric algorithm.Before going to implementation details let discuss some security related terms before.What is Hashing


Hashing is one-way algorithm, means once the data is hashed you can’t recovered it latter.
Hashing is a cryptographic function that is used to provide a secure fingerprint of data. A common usage you may have encountered is to check a file you have downloaded.
What is Encryption
If you want to secure your data, and latter you want to retrieve the original data. We used encryption because encryption is two-way processes. For encryption we requires following things
Key:Key is a piece of information that is used as an input parameter in encryption. The output of encryption is determined by the key.
Types of Encryption
are two main types of encryption and decryption algorithms, symmetric and asymmetric.Symmetric: In symmetric encryption we used same key for encryption and dec…