Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Removing Padded Value in Decrypted Message

I tried to encrypt and decrypt a file in ECB mode using AES Algorithm but I encountered one problem during decryption, I don't know how to remove the padded value.. because every byte in a file is unpredicted.. I am only using 0x00 in padding.

how to remove the padded value in a encrypted file during decryption? how can I also determined that is a padded value and not a original byte of a file.

share|improve this question

marked as duplicate by poncho, Paŭlo Ebermann Jun 5 '12 at 20:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Sorry, it is not really clear how this differs from your previous question. If you think your previous question needs clarification, feel free to edit it. – Paŭlo Ebermann Jun 5 '12 at 20:06

To repeat the answer I gave you, with zero padding; "if you can assume that the message will never end in a zero byte, then it is easy to remove. If you can't make that assumption, it sounds like you may need to switch to another padding method".

So, to answer your question "how can I determine that it is a padded value and not an original byte of the file", the answer is "you can't -- switch to a padding method where you can".

share|improve this answer
is it okay to create my own padding method? – goldroger Jun 6 '12 at 3:53
@JohnPaulParreño Why create your own? There are more than enough padding methods already. – CodesInChaos Jun 6 '12 at 13:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.