CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2007
    Posts
    3

    Red face How to do Tripple DES decryption in C#.

    Hi, i have a algorithm that processes some input byte as the following:


    Output Byte = DES-1(keyLeft, DES(keyRight, DES-1(keyLeft, inputByte)))



    i try to use c# TripleDES class decryptor method to implement this algo but no luck. I either get my exception error of "bad data" or there is no output from the method. So i wonder if anybody know how to do DES decryption in c#.


    byte[] inputByte = new byte[8];

    byte[] key = new byte[24];

    byte[] initVal = new byte[8];

    byte[] outputByte = new byte[8];


    //////////////////////////////////////////

    // Some inititalization of key and inputByte.
    // Actual value not shown here.

    input Byte = ......
    key = ......

    Array.clear(initVal, 0, 8);



    //////////////////////////////////////////


    TripleDES tdes = TripleDES.Create();

    tdes.Key = key;
    tdes.IV = initVal;


    ICryptoTransform ict = tdes.CreateDecryptor();
    tdes.Mode = CipherMode.ECB;

    outputByte = ict.TransformFinalBlock(inputByte, 0, 8);

  2. #2
    Join Date
    Dec 2003
    Location
    Montreal
    Posts
    58

    Re: How to do Tripple DES decryption in C#.

    There is a good example in the TripleDESCryptoServiceProvider Class on MSDN (TripleDESCryptoServiceProvider Help) which is the wrapper class for TrippleDES.
    Last edited by CJ1; November 1st, 2007 at 10:13 AM.

  3. #3
    Join Date
    Oct 2007
    Location
    Alaska
    Posts
    62

    Re: How to do Tripple DES decryption in C#.

    English is bad, but the code is good: http://www.codeproject.com/useritems..._an_string.asp
    Microsoft Framework Programmer
    http://kensino.com

  4. #4
    Join Date
    Oct 2007
    Location
    Alaska
    Posts
    62

    Re: How to do Tripple DES decryption in C#.

    Microsoft Framework Programmer
    http://kensino.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured