Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key length issue in crypto.encrypt API #36

Open
kpushpad opened this issue Oct 31, 2014 · 1 comment
Open

key length issue in crypto.encrypt API #36

kpushpad opened this issue Oct 31, 2014 · 1 comment

Comments

@kpushpad
Copy link

I am using crypto.encrypt("AES128", text, key) API to encrypt our data. But whenever i pass key whose size is more than 32 bytes/char it say invalid key.

Is there anyway i can pass longer keys ? or this is a bug ?

@kpushpad kpushpad changed the title kpushpad key length issue in crypto.encrypt API Oct 31, 2014
@mkottman
Copy link
Owner

On Oct 31, 2014 3:28 PM, "kpushpad" [email protected] wrote:

I am using crypto.encrypt("AES128", text, key) API to encrypt our data.
But whenever i pass key whose size is more than 32 bytes/char it say
invalid key.

Is there anyway i can pass longer keys ? or this is a bug ?

This is not a bug, it's a feature (of most ciphers) - the key has a certain
fixed length - in your case 128 bits. Keys shorter than that get padded,
but obviously you can't use longer keys.

The standard aproach is to first hash the password with a 128 bit (160,
256, depending on cipher/configuration) hash and use that as a key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants