Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What encryption algorithm is best for small strings?

Tags:

I have a string of 10-15 characters and I want to encrypt that string. The problem is I want to get a shortest encrypted string as possible. I will also want to decrypt that string back to its original string.

Which encryption algorithm fits best to this situation?

like image 655
Lee Shtoy Avatar asked Jun 16 '10 07:06

Lee Shtoy


People also ask

Which is better RSA or AES?

The Advance Encryption Standard (AES) cipher text method is a more accurate and elegant cryptographic method. According to testing results and the text files used, it has been concluded that the AES algorithm outperforms the Data Encryption Standard (DES) and RSA algorithms [6,7].

How good is AES 256 encryption?

AES-256, which has a key length of 256 bits, supports the largest bit size and is practically unbreakable by brute force based on current computing power, making it the strongest encryption standard.

What is the simplest encryption algorithm?

Caesar's cypher is the simplest encryption algorithm.


1 Answers

AES uses a 16-byte block size; it is admirably suited to your needs if your limit of 10-15 characters is firm. The PKCS#11 (IIRC) padding scheme would add 6-1 bytes to the data and generate an output of exactly 16 bytes. You don't really need to use an encryption mode (such as CBC) since you're only encrypting one block. There is an issue of how you'd be handling the keys - there is always an issue of how you handle encryption keys.

If you must go with shorter data lengths for shorter strings, then you probably need to consider AES in CTR mode. This uses the key and a counter to generate a byte stream which is XOR'd with the bytes of the string. It would leave your encrypted string at the same length as the input plaintext string.

You'll be hard pressed to find a general purpose compression algorithm that reliably reduces the length of such short strings, so compressing before encrypting is barely an option.

like image 102
Jonathan Leffler Avatar answered Sep 23 '22 12:09

Jonathan Leffler