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

Recommended way to update keys? #259

Closed
lcpriest opened this issue Mar 10, 2017 · 4 comments
Closed

Recommended way to update keys? #259

lcpriest opened this issue Mar 10, 2017 · 4 comments

Comments

@lcpriest
Copy link

Context: I am currently updating my Gemfile to a later version of this gem; my keys are currently throwing 'key must be 32 bytes' errors; my current keys are longer than this.

Is there a recommended way to deserialize encrypted attrs and re-encrypt them with a new key?

My base assumption would just be to add a new column using a 32 byte key and them decrypt -> re-encrypt in the new column, then migrate to the new version of the gem.

Alternatively, is there a way to allow longer keys?

@saghaulor
Copy link
Contributor

@lcpriest If you're using Ruby 2.4.x, it now requires keys to be the same bit length as the cipher used. However, as documented in attr-encrypted/encryptor#26, previous versions of Ruby actually didn't use the extra bits, rather, it simply ignored them. You should be able to just use the first 32 bytes and everything should continue to work. As such, I don't believe you need to migrate.

@saghaulor saghaulor reopened this Mar 10, 2017
@saghaulor
Copy link
Contributor

Are you still concerned with updating keys? If not I would like to close this issue.

@lcpriest
Copy link
Author

lcpriest commented Mar 10, 2017 via email

@encinas008
Copy link

Yes, only is cut to 32bits your key
E.g. d22e8ad01da954c2950fffdbef8016210a26bb73a0e61b0a5dc93639481f2eafa9662d286a9d974bdf3a8c608893cb1d89f827f116800752137f03743c05b9db

cut to d22e8ad01da954c2950fffdbef801621 --> 32 bits

that's works for me.

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

3 participants