String Encryption Algorithm
Posted Date Unknown Sonia George Sonia George 1 Comment

Hi 


I want a string to encrypt and save it to the database. I got the code below.

 

public static string Encrypt(string strToEncrypt, string strKey)

{

    try

    {

        TripleDESCryptoServiceProvider objDESCrypto =

                          new TripleDESCryptoServiceProvider();

        MD5CryptoServiceProvider objHashMD5 = new MD5CryptoServiceProvider();

        byte[] byteHash, byteBuff;

        string strTempKey = strKey;

        byteHash = objHashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(strTempKey));

        objHashMD5 = null;

        objDESCrypto.Key = byteHash;

        objDESCrypto.Mode = CipherMode.ECB;

        byteBuff = ASCIIEncoding.ASCII.GetBytes(strToEncrypt);

        return Convert.ToBase64String(objDESCrypto.CreateEncryptor().

                          TransformFinalBlock(byteBuff, 0, byteBuff.Length));

    }

    catch (Exception ex)

    {

        return "Wrong Input. " + ex.Message;

    }

}

 

I would like to know which algorithm is used in the code above. Please anyone give me the answer...


See All Responses Below...
Author
Message Rating
Posted on: 23/05/2012
The code uses MD5 togenerate the output. MD5 is a one-way hashing algorithm which means that it's not possible to reverse the algorithm to get the original value back. Hashing is not encryption. So TripleDES is used to retrieve it back.
Please Login to Post Your Comments
Name (Max. 100 characters)
Please post your comments here
Select Language
Comments
Attach File(Max. Size: 2 MB)
A few simple rules when posting your Comments,
  1. Please post only answers relevant to the topic of discussion.
  2. Please dont misuse this site or do not be abusive, offensive, inappropriate,harass anyone on the boards or post ads or spam. Doing so will delete your inappropriate messages and will block or delete your account on this site. 

TekTipsDownload
GateExam
Academic Projects
TekTipsExperts



 
Site optimized for IE7, 1280 X 768 and above. Copyright © 2010 - 2018 KTS InfoTech
Site Developed Using KTS WebCloud