i have a question about SHA256 I know that this algorytm was used to encrypt a text, wich i have, also i have the encrypted version of this text. My question is can i somehow get to the encryption key with those infos ?

  • 4
    This belongs in crypto.stackexchange.com. – Peter Andersson Apr 12 '13 at 9:55
  • I know this is closed, but on the whole, I think a single downvote is enough to signify that an question is poor. – Cybergibbons Apr 12 '13 at 14:10
  • @Cybergibbons: well, true. Still on SO and other SE sites it would have gotten a whole lot worse. You can always upvote to counter the downvotes. Upvotes also outweigh downvotes in terms of rep change. – 0xC0000022L Apr 12 '13 at 14:46
  • Agree. This is a bit meta, but I notice on the smaller SE sites with a better community (like the electronics one), -1 signifies "really bad question" and 0 "could be better". – Cybergibbons Apr 12 '13 at 15:28

SHA256 is a hash. It doesn't have a key. It's a one way transformation function from input a to output b which is irreversible. The best you can do is to try various inputs until you get your output.

  • This is obviously correct, and you know everything that follows, but since I already wrote it.. Despite the author's confusion, he is asking a more fundamental question I believe, one that does belong on crypto.stackexchange.com. That is: Can a symmetric key be derived if the plaintext is known? The answer is generally that it makes it possible, if not easy, depending on the encryption algorithm. In some cases, simply knowing a few bytes of plaintext can yield the key, or substantially reduce the range of possible keys. – dyasta Apr 14 '13 at 13:14
  • Unless it’s HMAC! @90h: Can you give an example of an algorithm? I don’t know of anything standard (XOR doesn’t count! :P) that can be attacked by knowing the plaintext, that’s part of the evaluation they go through. AES and DES certainly don’t make it easy given a few bytes. – Ry- Apr 14 '13 at 17:02
  • Darn it, XOR was going to be my prime example ;p. There are other, similarly less advanced, algorithms that can clearly be broken if part of the plaintext is known. This is especially true when the algorithm is known and if the known plaintext is longer than the key. For block chaining encryption algorithms, it is particularly helpful to know the first few bytes. Even sophisticated symmetric encryption algos can be broken, or weakened, by knowing the plaintext. The simple math reality of: A+B=C so A=C-B makes this true. Cryptanalyists often use this mechanism. – dyasta Apr 14 '13 at 17:08
  • But I'm sure you're right that GOOD encryption algorithms can't be so easily broken with the plaintext. Whether they can be weakened though, I don't know for sure. Depends on the algorithm, but this is hard to avoid entirely (though maybe the good ones do, I'm not sure on that). – dyasta Apr 14 '13 at 17:09

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