Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem when trying to decryp encryped file with CryptoPP (C++)

  1. Jun 15, 2009 #1
    Hi all,

    I have a problem.

    Someone I know encrypted a text file using AES128 by using binary key file, (He generate the binary key).
    After that he uses "base64Encode" over the encryped file

    I have the private binary key file.
    Now, when I'm trying to decrypt the file, I do as follow:
    1. Use "Base64Decoder" to get the encrypted file --> Pass successfully
    2. Use the following:

    Try using both functions:
    in - is the input file (encrypted file)
    passPharse - char* - location of the key file

    but I always getting the following error:

    Now when I'm trying to encrypt and decrypt by myself it works fine,
    (I'm using the binary key he gave me)

    Could anyone help me to understand what is my problem?
    I'm guessing that the problem could be from 2 reasons:
    1. Because this is a different algorithm form java AES128
    2. There is a problem in the key, It can't read it right
  2. jcsd
  3. Jun 15, 2009 #2


    User Avatar

    I don't know anything about the implementation you are using so I don't know whether your code is correct, but from my experience such problems are usually the result of using different padding schemes.

    Also, since it's AES, make sure you are using the same mode (ECB, CBC, CTR...) and initialization vector, if appropriate.

    I'm pretty sure one of these two is the problem if your program correctly decrypts the stuff it encrypts.
    Last edited: Jun 15, 2009
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook