2
$\begingroup$

I have the following text that I want to encrypt with a password:

"This is my secret password: 1234567890"

encrypted with AES:

SgAHzFc3vluxLqZuzZKg8dzhy918N41SUU1BfBXN8CoEDfVJ0R9hox8PT2jKYA==

pass: 12345

When I encrypt this with a password using AES, the encrypted string is 64 characters.

Is there another type of encryption that is less than 64 characters? Or maybe there is an encryption that also compresses the encrypted string?

$\endgroup$
3
  • $\begingroup$ Which program did you used? $\endgroup$
    – kelalaka
    Commented Oct 15, 2018 at 17:13
  • $\begingroup$ I'm still looking. Open to suggestions. $\endgroup$ Commented Oct 15, 2018 at 17:19
  • $\begingroup$ General ciphertext expansion rate for CTR mode encoded text is 4/3 + 16 bytes + 16 to 43 bytes for authentication, so a plaintext of 38 bytes would be around 83 bytes ciphertext, yours is 64, which would mean no authentication (and actually looks too short, was it compressed?) $\endgroup$ Commented Oct 16, 2018 at 0:22

2 Answers 2

1
$\begingroup$

1. is there another type of encryption that is less than 64 characters?

There is a Format Preserving Encryption(FPE) that might interest you. FPE is exactly designed for short plaintext spaces.

From Wikipedia;

In cryptography, format-preserving encryption (FPE), refers to encrypting in such a way that the output (the ciphertext) is in the same format as the input (the plaintext). The meaning of "format" varies.

  • To encrypt a 16-digit credit card number so that the ciphertext is another 16-digit number.
  • To encrypt an English word so that the ciphertext is another English word.
  • To encrypt an n-bit number so that the ciphertext is another n-bit number

The NIST has two standards named FFX and BFS.

However, keep in mind that, since the plaintext size is so small, someone who accesses the encryption oracle can perform a dictionary attack.

2. Or maybe there is an encryption that also compresses the encrypted string?

I don't know any scheme. But you can compress plaintext before encryption. This is what we do to reduce the cost of the transfer. And note that this not about security.

$\endgroup$
4
  • $\begingroup$ Would you know of any javascript libraries that implements these 2 methods? $\endgroup$ Commented Oct 15, 2018 at 17:41
  • $\begingroup$ This link might help you. Contains implementation for various languages. $\endgroup$
    – kelalaka
    Commented Oct 15, 2018 at 17:44
  • $\begingroup$ I'm actually using a Vigenère cipher that I wrote in javascript. Its this the same as a FPE encryption? $\endgroup$ Commented Oct 15, 2018 at 17:48
  • 1
    $\begingroup$ @Patoshiパトシ No way. From wiki; John Black and Phillip Rogaway which described three ways to do this. They proved that each of these techniques is as secure as the block cipher that is used to construct it. $\endgroup$
    – kelalaka
    Commented Oct 15, 2018 at 18:07
2
$\begingroup$

You don't say what mode of operation you are using with AES. The mode of operation can have a big impact on the ciphertext expansion. There are streaming modes, such as CTR, for which the ciphertext will be the same size as the plaintext. For these modes (an pretty much any mode you would want to use in practice) you will also have to transmit a nonce or IV in addition to the ciphertext.

One thing you should be aware of is that modes like CTR are malleable, which is a huge security issues. So, I highly recommend you use authenticated encryption so that you don't have these security issues. This could be done by computing an HMAC over the ciphertext or using an authenticated mode.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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