11

If an encrypted text is decrypted with its corresponding key, we would get the plaintext. However, what if I were to decrypt plain text? What would result? An error or some nonsensical number?

Mike Ounsworth
  • 57,707
  • 21
  • 150
  • 207
weejing
  • 161
  • 2
  • 6

5 Answers5

34

"Encryption" is a large term. In all generality, encryption takes an input message in some space of possible input messages; usually arbitrary "sequences of bits" with various restrictions on length, e.g. "length in bits must be a multiple of 8" (i.e. input must be a sequence of bytes), or "length must not exceed 245 bytes" (typical of asymmetric encryption with RSA in PKCS#1 v1.5 mode, with a 2048-bit RSA key). The output is al part of some space of possible output messages.

Computers being computers, both input and output messages are ultimately encoded in sequences of bits, so it may happen that input and output message spaces overlap, in which case you can conceptually take an input message (a "plaintext"), interpret it as an output message, and try to decrypt it. This is not necessarily possible: for instance, with RSA asymmetric encryption (PKCS#1 v1.5) and a 2048-bit key, input messages (plaintexts) are arbitrary sequences of 0 to 245 bytes (inclusive) while output messages (ciphertexts) are sequences of exactly 256 bytes, so it is not possible, in such a case, to try to "decrypt a plaintext": possible plaintexts are not long enough to feed the decryption engine.

When you can "decrypt a plaintext", what happens depends on the encryption system. Usually, when decryption works at all, what you get is essentially random-looking nonsense. In some cases, encryption is an involution (e.g. stream ciphers such as RC4 that work by XORing the message with a key-dependent stream), meaning that decryption and encryption are actually the same operation, so by "decrypting" the plaintext you are actually encrypting it.

However, it may also happen that not all sequences of bits of the right length are valid ciphertexts. For instance, consider a block cipher in CBC mode. To encrypt a message m, you must:

  1. Pad the message to a length multiple of the block size, by appending between 1 and n bytes (n is the block size) with some specific contents.

  2. Generate a new random IV of the same size as the block size.

  3. Apply CBC encryption on the padded message, using that IV.

  4. Output is the concatenation of the IV and the encryption result.

In such a case, when decrypting, not only must the length be a non-zero multiple of the block size, but after decryption, a valid padding must be found. If using the usual "PKCS#7 padding" (when adding k bytes, all added bytes have value exactly k), the probability that a plaintext of a compatible length actually decrypts to something with a valid padding is about 1/255. In that case, "decrypting the plaintext" will produce a decryption error 99.61% of the time, and some random-looking junk the remaining 0.39%.

Good encryption system include a MAC, in which case attempting to decrypt something which was not the result of encryption with the same key should result in a duly reported decryption error with overwhelming probability.

Summary: when you try to do something that does not make sense, you can obtain various results.

Tom Leek
  • 168,808
  • 28
  • 337
  • 475
  • 26
    *Summary: when you try to do something that does not make sense, you can obtain various results.* Good summary, this extends to programming (and life). – Hey Apr 15 '16 at 18:52
5

It depends on what cipher you use. For example, with the famous and very secure (sarcasm) ROT13 algorithm, encryption and decryption are the same operation. If you decrypt a plaintext, actually, you just encrypted it.

With a more modern cipher like AES, you will likely get a big nonsensical number. I think it will be the same for most ciphers.

Mark Buffalo
  • 22,498
  • 8
  • 74
  • 91
Hey
  • 1,905
  • 1
  • 16
  • 23
  • 4
    Yes, with one clarification that it depends on the mode of operation. AES in a block mode (such as CBC) has a function for encryption and an inverse function for decryption, so attempted to decrypt a plaintext will, as you say, result in nonsense. AES in a streaming mode however, (such as CTR) using the same function for both encryption and decryption and so will simply result in a ciphertext. – Xander Apr 15 '16 at 17:42
  • 3
    Generally speaking, with a stream cipher (or a block cipher in a streaming mode of operation) encryption and decryption are the same function. – Xander Apr 15 '16 at 17:43
  • 1
    Even worse is ROT26 this message was encrypted with it – Booga Roo Apr 16 '16 at 09:50
0

Decryption is merely applying an algorithm to a dataset using a key. Broadly speaking, this is the same as encryption, though the algorithms for encrypt and decrypt may differ. In fact, for some encryption algorithms, encryption is the same algorithm as decryption.

So, broadly speaking, if you apply the "decrypt" algorithm to a plaintext, you'll get a ciphertext encrypted with the decrypt algorithm.

This may not always work of course, depending on the encryption scheme. You might get back an error when you try this. I don't believe this would work with the RSA algorithm for instance.

Whether applying "encrypt" to this ciphertext would get you the plaintext back would depend on the encryption scheme.

Steve Sether
  • 21,480
  • 8
  • 50
  • 76
-4

Please do not decrypt plain text. Very bad things will happen. You could cause a Server Fault, a Stack Overflow, or anger the Super User. It's possible nothing will happen, and it's possible nothing bad will happen. It depends on the text that you're trying to decrypt.

For example, War and Peace might suddenly cause your PC to morph into the reincarnation of a Cyborg zombie Hitler because it's really the 1000 times encrypted Mein Kampf. Meanwhile, decrypting The Bible might bring about an actual Raptor Jesus due to the sheer belief of The Internets in Him.

The more likely scenarios are that you would cause some kind of physics meltdown in your computer, possibly releasing spurious particles or waves, like neutrons, Bogons, or Morons. We don't need waves of spurious Morons!

Absolute worst case scenario: your computer divides by zero and your house ends up looking like this:

enter image description here

If you could not tell, this was a bit of humor to address the question at face value, and the preceding is not to be taken seriously. Like others have said, there are a lot of variables at play, namely the type of encryption/decryption and specific methods and algorithms used. If you put plain text into a decryption function, in all seriousness, you'll likely get some kind of gibberish out.

However, it is possible to make an algorithm or function to obscure a message in plain text that could be decrypted into another plain text message. However, that would just be another form of encryption and would more likely encrypt words instead of characters. In this case words like English words instead of the computer science words.

YetAnotherRandomUser
  • 2,290
  • 2
  • 14
  • 20
  • 2
    if you encrypt plain text, you get gibberish out, too. – schroeder Apr 16 '16 at 16:29
  • @schroeder Oh dear, I guess we'll need to stop encrypting our messages to be safe! Seriously though, this answer is just silly, and not because of the attempted humor. It's just... wrong. – forest Mar 16 '18 at 07:10
-5

Interesting question......

But the result would be some funny looking characters because the decryption process will treat your plaintext as encrypted data and try to decrypt it with a provided key.

Mero55
  • 835
  • 1
  • 8
  • 9
  • "funny looking characters"? You might need to explain that one. I think you are thinking about different character sets. – schroeder Apr 15 '16 at 17:49
  • 4
    @schroeder Well, if I took `poem.txt`, ran it through a decryption routine and then opened the result in notepad, I would expect to see character-set puke. Not that this answer really gives any insight into what's going on behind the scenes though. – Mike Ounsworth Apr 15 '16 at 18:39