# Repair AES-128 decrypted file

I decrypted a file which was encrypted with OpenSSL and AES-128 with the wrong password. Before I noticed it was the wrong password I removed the original file. Is there a possibility to reproduce the original encrypted file? I know the "wrong" password.

EDIT

The only file I have is the wrong decrypted file. I tried to re-encrypt that file with the used password - the password I decrypted the original file - but that doesn't work. Is there another way to get the original encrypted file?

• Um, your question is not clear. You say you know the "wrong" password, so just decrypt the files. If you don't know the used password anymore and there's no way to get it from OpenSSL, then your files are lost. – Nova Mar 11 '15 at 23:04
• I decrypted the file with a wrong password. Now I just have that wrong decrypted file. I tried to re-encrypt that file with the wrong password to get the original encrypted file, but that didn't word. Is there another way to get the original encrypted data? – Paul Warkentin Mar 11 '15 at 23:07
• Can you tell us the exact openssl command you used? In particular, which cipher mode did you use, and did you use a salt? – Ilmari Karonen Mar 11 '15 at 23:45
• So you did encrypt some special files. Then you tried to decrypt them, but with a wrong password. The original plaintext and the "correct" encrypted file are gone. Is that correct? – Nova Mar 11 '15 at 23:47
• If you only "removed" the good file but didn't "wipe" or "securely delete" it, depending on your OS and filesystem and what else you have done on that filesystem since it may be possible to "undelete" (recover) it, or at least part of it; if you can get the first 16 bytes (which contain the salt, as explained by @Stephen) that's enough to (mostly?) recover. That's not a crypto.SE question; superuser.com might be suitable. – dave_thompson_085 Mar 12 '15 at 8:24

• Nitpick: openssl enc does do PBE in most cases including this one, but it does NOT hash "a large number of times" as PBE should; instead it does a variant of PBKDF1 (old, but tolerable) with iteration count 1 YES I SAID ONE. Unlike other openssl defaults that were reasonable when chosen a decade or two ago but now superseded or deprecated, n=1 was bad from the start. But as you say the problem here is the salt and that was done right. – dave_thompson_085 Mar 12 '15 at 8:35