CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2005
    Posts
    42

    Question Triple DES Encryption

    Following code decrypts the encrypted string "thisDecode" but gives an error:
    (Unhandled Exception: System.Security.Cryptography.CryptographicException: Bad Data.
    at System.Security.Cryptography.CryptoAPITransform._DecryptData(IntPtr hKey,
    Byte[] rgb, Int32 ib, Int32 cb, Boolean fDone)
    at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[]
    inputBuffer, Int32 inputOffset, Int32 inputCount))


    Code:
    TripleDESCryptoServiceProvider* des;
    des = new TripleDESCryptoServiceProvider();
    des->GenerateKey();
    des->GenerateIV();

    ICryptoTransform *Decryptor;
    Decryptor = des ->CreateDecryptor();
    ASCIIEncoding* ascii2 = new ASCIIEncoding();
    Byte DCode[] = Convert::FromBase64String(thisDecode);
    String* decrypted;
    decrypted = ascii2->ASCII->GetString(Decryptor->TransformFinalBlock(DCode, 0, DCode->Length),0,DCode->Length);
    return decrypted;

    Help needed regarding this.
    Thanks.

  2. #2
    Join Date
    Apr 2005
    Posts
    42

    Angry Re: Triple DES Encryption

    any one here knows Triple DES Decryption

  3. #3
    Join Date
    Jun 2005
    Posts
    20

    Re: Triple DES Encryption

    Sorry for the Delay in response.

    The long and the short is YES.

    In fact I have a report i could lend you on the encryption method and some source code if you need it. It's in C++.

    Bill

    I'm not sure about what your code is referring to, or what it means. Basically I just finished making my program to encrypt and decrypt a file. The program isn't complete, but it works, and it demonstrates the process. If you're trying to use a program that was already created I wish you luck. The DES algorithm isn't all that difficult if you have someone who is capable of explaining it to you, but otherwise it can be a bit annoying. I do recommend that you write your own program though for the simple fact that if you write your own program, well then you know how that works.


    I put some source code on my site in case you still need some help. It was written on MS Visual C++ 6.0

    http://tex23bm.mikee385.com/
    Last edited by tex23bm; June 29th, 2005 at 11:38 PM.

  4. #4
    Join Date
    Apr 2005
    Posts
    42

    Smile Re: Triple DES Encryption

    Thanks for your reply, but i got a solution for my problem. Actually i am working in .net, and using its inbuilt libraries of cryptography. This is much easier to work on, instead of working on VC6. It just requires few lines of code to implement DES/Triple DES, in comparison with VC6.
    If you are interested in code of Triple DES implemented in C#, i can provide you that.

  5. #5
    Join Date
    Feb 2013
    Posts
    4

    Re: Triple DES Encryption

    hi I need a code of triple des in c++ for encryption and decryption can any one help me plz. thanx

  6. #6
    Join Date
    Feb 2013
    Posts
    4

    Re: Triple DES Encryption

    the site you put didn't open.

  7. #7
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Triple DES Encryption

    Quote Originally Posted by memo jar View Post
    the site you put didn't open.
    No big surprise I'd say: The post is almost eight years old.

    I can't give you an implementation of 3DES either, but the Wikipedia article may take you somewhat further. It refers to the article on DES, which describes the algorithm in detail so you may be able to implement it. The fourth external link from the article page seems to more specifically describe a concrete implementation and may even contain source code; I didn't take the effort to download and inspect the PostScript file, though. Once you've got the DES part working, it shouldn't be too difficult to implement 3DES based on that and the information from the first article I linked to.

    HTH
    Last edited by Eri523; February 8th, 2013 at 07:34 PM.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  8. #8
    Join Date
    Feb 2013
    Posts
    4

    Re: Triple DES Encryption

    plz the fourth external link from the article page did not open. in which program i must open it

  9. #9
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Triple DES Encryption

    Ghostscript should be able to open it.

    Alternatively, a Google search for "Open PostScript file" may yield some useful results.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

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