0
votes

Is it possible to encrypt a file in Java with AES algorithm of Block size 128 bits and key size 256 characters(bytes) ?

As per references the key size can be of maximum 256 bits or 32 characters.

I have a requirement to do with 256 characters, is it possible ?

1
Sure, you can use a MessageDigest to hash the password and take as many bits as you need from the digest result. - Erwin Bolwidt
Do not use a MessageDigest to derive a key, it is not sufficient and just adding a salt does little to improve the security. Instead iIterate over an HMAC with a random salt for about a 100ms duration and save the salt with the hash. Use functions such as PBKDF2 (aka Rfc2898DeriveBytes), password_hash/password_verify, Bcrypt and similar functions. The point is to make the attacker spend a lot of time finding passwords by brute force. Protecting your users is important, please use secure password methods. - zaph

1 Answers

1
votes

AES has one block size of 128-bits and three key sizes of 128, 192 & 256 bits.

If you have a 256 characters, characters depending on the encoding can be more than 1 byte, you can use a key derivation method such as PBKDF2 (Password Based Key Derivation Function 2) to derive a key from the characters.

See the comment to the question.