lib/ectoken/ectoken.rb in verizon_token-0.1.0 vs lib/ectoken/ectoken.rb in verizon_token-0.2.0
- old
+ new
@@ -5,11 +5,11 @@
module EdgeCastToken
class Token
def self.encrypt(key, token)
digest = Digest::SHA256.digest(key)
- cipher = OpenSSL::Cipher::AES.new(256, :GCM).encrypt
+ cipher = OpenSSL::Cipher.new('aes-256-gcm').encrypt
iv = cipher.random_iv
cipher.iv = iv
cipher.key = digest
cipher_text = cipher.update(token) + cipher.final
cipher_with_iv = iv + cipher_text + cipher.auth_tag
@@ -19,10 +19,10 @@
def self.decrypt(key, token)
digest = Digest::SHA256.digest(key)
decoded_token = Base64.urlsafe_decode64(token)
iv = decoded_token[0..11]
decipher_text = decoded_token[12..decoded_token.length-17]
- decipher = OpenSSL::Cipher::AES.new(256, :GCM).decrypt
+ decipher = OpenSSL::Cipher.new('aes-256-gcm').decrypt
decipher.iv = iv
decipher.key = digest
decipher.update(decipher_text)
end
end
\ No newline at end of file