jmazzi / crypt_keeper

Transparent ActiveRecord encryption
http://jmazzi.github.com/crypt_keeper/
MIT License
288 stars 99 forks source link

uninitialized constant CryptKeeper::Provider::AesNew #133

Closed bliaxiong closed 7 years ago

bliaxiong commented 7 years ago

I'm trying to test this gem out with a simple app and getting uninitialized constant CryptKeeper::Provider::AesNew. Using Ruby 2.3.1 and Rails 5.0.0. I scaffold a blog and have the following:

class Blog < ApplicationRecord
    crypt_keeper :title, :body, :encryptor => :aes_new, :key => 'super_good_password', salt: 'salt', :encoding => 'UTF-8'
end

Not sure why its throwing that error when I try to create a Blog. Thanks in advance!

safetymonkey commented 6 years ago

Did this get closed because any action was taken? I'm getting the same error:

An error occurred while loading ./spec/models/direct_ftp_delivery_spec.rb.
Failure/Error:
  crypt_keeper :password, encryptor: :aes_new, key: 'I think super long ' \
    'passwords tend to be the best ones, don\'t you?', salt: 'sodium chloride'

NameError:
  uninitialized constant CryptKeeper::Provider::AesNew
# ./app/models/direct_ftp_delivery.rb:5:in `<class:DirectFtpDelivery>'
# ./app/models/direct_ftp_delivery.rb:2:in `<top (required)>'
# ./spec/models/direct_ftp_delivery_spec.rb:3:in `<top (required)>'

An error occurred while loading ./spec/models/direct_sftp_delivery_spec.rb.
Failure/Error:
  crypt_keeper :password, encryptor: :aes_new, key: 'I think super long ' \
    'passwords tend to be the best ones, don\'t you?', salt: 'sodium chloride'

NameError:
  uninitialized constant CryptKeeper::Provider::AesNew
# ./app/models/direct_sftp_delivery.rb:5:in `<class:DirectSftpDelivery>'
# ./app/models/direct_sftp_delivery.rb:2:in `<top (required)>'
# ./spec/models/direct_sftp_delivery_spec.rb:3:in `<top (required)>'
Run options: exclude {"mysql_db"=>true, "postgres_db"=>false, "oracle_db"=>true, "ldap"=>true}
jmazzi commented 6 years ago

@safetymonkey have you tried the same code in a newly generated rails app? Does the error happen then?

itspriddle commented 6 years ago

Just wanted to point out that the AesNew encryptor was removed in 2.0.0.rc1 (see #140) – so if you are using the release candidate this is expected behavior.

safetymonkey commented 6 years ago

Yeah, I changed the encryptor over to active_support (thanks for that, by the way!) and all my tests started passing. Based on the comment from @itspriddle it sounds like I don't need to go replicate. Thanks for the assistance!