-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from jmazzi/refactor/goodbye-aes
Replace AesNew provider with ActiveSupport::MessageEncryptor
- Loading branch information
Showing
17 changed files
with
155 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "activerecord", "~> 5.0.0" | ||
gem "activesupport", "~> 5.0.0" | ||
|
||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require "active_support/message_encryptor" | ||
|
||
module CryptKeeper | ||
module Provider | ||
class ActiveSupport < Base | ||
attr_reader :encryptor | ||
|
||
# Public: Initializes the encryptor | ||
# | ||
# options - A hash, :key and :salt are required | ||
# | ||
# Returns nothing. | ||
def initialize(options = {}) | ||
key = options.fetch(:key) | ||
salt = options.fetch(:salt) | ||
|
||
@encryptor = ::ActiveSupport::MessageEncryptor.new \ | ||
::ActiveSupport::KeyGenerator.new(key).generate_key(salt, 32) | ||
end | ||
|
||
# Public: Encrypts a string | ||
# | ||
# value - Plaintext value | ||
# | ||
# Returns an encrypted string | ||
def encrypt(value) | ||
encryptor.encrypt_and_sign(value) | ||
end | ||
|
||
# Public: Decrypts a string | ||
# | ||
# value - Cipher text | ||
# | ||
# Returns a plaintext string | ||
def decrypt(value) | ||
encryptor.decrypt_and_verify(value) | ||
end | ||
|
||
# Public: Searches the table | ||
# | ||
# records - ActiveRecord::Relation | ||
# field - Field name to match | ||
# criteria - Value to match | ||
# | ||
# Returns an Enumerable | ||
def search(records, field, criteria) | ||
records.select { |record| record[field] == criteria } | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.