lib/ectoken/ectoken.rb in verizon_token-0.2.2 vs lib/ectoken/ectoken.rb in verizon_token-0.2.3
- old
+ new
@@ -3,18 +3,18 @@
require 'openssl'
require 'optparse'
module EdgeCastToken
class Token
- def self.encrypt(key, token)
+ def self.encrypt(key, token, padding = true)
digest = Digest::SHA256.digest(key)
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
- Base64.urlsafe_encode64(cipher_with_iv)
+ Base64.urlsafe_encode64(cipher_with_iv, padding: padding)
end
def self.decrypt(key, token)
digest = Digest::SHA256.digest(key)
decoded_token = Base64.urlsafe_decode64(token)
\ No newline at end of file