-2

i found a source for android encryption..its using AES 128 Bit encryption..but the number of secret key is fix to 16character..can anyone tell me how to change the number secret key as our wish..i don't want limit the character for secret key..

here is the link

https://sites.google.com/site/mobilesecuritylabware/3-data-location-privacy/lab-activity/cryptography/cryptography-mobile-labs/encryption-decryption/2-lab-activity/lab-activity

user3564082
  • 1
  • 1
  • 3
  • Good starting point is [Java 256-bit AES Password-Based Encryption](http://stackoverflow.com/questions/992019/java-256-bit-aes-password-based-encryption) where there are examples how to obtain proper AES key from a textual password of any length. – Oleg Estekhin May 26 '14 at 11:59

2 Answers2

3

Most symmetric encryption algorithm operate with blocks of fixed length and with keys of fixed length. For AES it's 16-byte block with 128-bit, 192-bit or 256-bit key. You can't have a different key length.

Now the key must ideally be 128-bit, not just "16 characters" (if you mean text symbols). 16 characters in ASCII alphabet is much less "meaningful" bits than 128. So to have 128 full-weight bits in encryption key you need to take a longer passphrase (at least 22 ASCII characters for 128-bit key), then apply one of key derivation functions (BCrypt, PBKDF) to your passphrase to get a key of the needed length.

The next thing to take into account is that you are now looking at low-level encryption where you will need to deal with cipher modes, padding etc. . If you are not well-acquainted with cryptography it makes sense to take a look at higher-level encryption standards which hide the low-level complexities from you. For example OpenPGP does surprisingly good job in encrypting the data using passphrases.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121
0

The reason it is called 128 bit encryption is that the key is 128 bits. 1 character is 8 bit, hence 16 characters. If you want another length key you can't use AES 128 bit encryption.

Ivo
  • 18,659
  • 2
  • 23
  • 35
  • 1
    16 characters is not the same as 128 random bits – Oleg Estekhin May 26 '14 at 11:55
  • What do you mean? following the link provided by the OP it even says "This is because the AES encryption algorithm we use is a 128-bit block cipher which must uses a 128-bit, a 192-bit or a 256-bit secret key. Here we set it to only accept a 16-character (128-bit) secret key for simplicity and we use "1111111111111111" as secret key for demonstration." – Ivo May 26 '14 at 11:59
  • @OlegEstekhin chars or bytes here is just a question of terms in this context, no reason to downvote. – Eugene Mayevski 'Callback May 26 '14 at 12:29