-2

Is it possible to encrypt a value (such as "hello world") with itself ("hello world") using an encrypting technique such as SHA256? Is that safe to do or would it be easily compromised?

ds_secret
  • 101
  • 4
  • 2
    SHA256 is a hash algorithm, not an encryption algorithm. It's not even _possible_ to do this as SHA256 doesn't use a key. – AndrolGenhald Aug 28 '18 at 20:53
  • 2
    I also don't understand the point... "I'm going to send you a secret message, but in order to open it, you have to already know what it is". What's the bigger goal you're trying to accomplish? – Mike Ounsworth Aug 28 '18 at 20:56
  • 1
    Encrypting something with itself as the key is [sometimes suggested](https://security.stackexchange.com/q/10476) as a home-made hashing solution, so if that's what you're after there's an answer for you (and that answer is don't do it). – AndrolGenhald Aug 28 '18 at 21:42

1 Answers1

4

Is it possible to encrypt a value (such as "hello world") with itself ("hello world") [...]

Is it possible, but not recommended in practice (see below).

using an encrypting technique such as SHA256?

No, SHA256 is not an encryption algorithm. SHA256 is used for hashing. Maybe you meant to write AES256 rather than SHA256?

Is that safe to do or would it be easily compromised?

It's not safe to do in a practical way since you would need to retain the key to decrypt the data, but since the key is the data in your proposed scheme that would mean that this proposed encryption scheme completely defeats its own purpose!

hft
  • 4,910
  • 17
  • 32