# Getting the encryption method and key from the encrypted data and the raw data

I have some pairs of plaintext and ciphertext data, from which I need to be able to decrypt the other passwords stored in the database.

The password field typically contains something like

• ENC:LCznyFywN+3J+AD330rqHg==
• ENC:D3H2ODVCAzkzQzRr8ZbJdw==

The raw data for the first is 1234, and the second 62369. ENC: denotes that it is an encrypted field, and the == at the end is always the same (no matter what the password).

If this can be done, then any prods in the right direction would be greatly received.

-
I doubt they're actually encrypted. More likely, it's a salted hash, which is intentionally selected because it is irreversible. –  David Schwartz Oct 19 '11 at 23:42
The third parties, have been able to give me my password hence my assumption that it is encrypted rather than a salted hash. –  CYMR0 Oct 20 '11 at 5:13
Thanks everybody. I know little about the world of crypto, so you have saved me from trying to complete an impossible task! –  CYMR0 Oct 20 '11 at 5:19
add comment

## 2 Answers

There is no general method for that. Cryptography is about making it impossible in practice.

In the particular examples, it looks like "encrypted data" is encoded in Base64, as 22 characters, representing 128 arbitrary bits. From that it can't be deduced much about the scheme used.

-
Thanks @fgrieu , it was worth a shot –  CYMR0 Oct 20 '11 at 5:17
add comment

What you are trying to do is called a known-plaintext attack.

A proper cipher will not be susceptible to a known-plaintext attack, so if the encryption method used on the strings in your database is any good, it can't be done.

Imagine that you were in fact using a (128 bit block) cipher that permits deducting the password given the plaintext and the ciphertext and you decide to use it to send encrypted emails to somebody.

If another person knows that your email ends with

Sincerely yours,

CYMR0


since this string is over 128 bits long, he can recover the password and, therefore, decrypt the entire email.

-
Thanks anyway @dennis –  CYMR0 Oct 20 '11 at 5:17
add comment