Sha256: d558ab019f8087e2caf2983b36091d8af3e184bc818fa1537dd50c10c0e4a62a
Contents?: true
Size: 782 Bytes
Versions: 3
Compression:
Stored size: 782 Bytes
Contents
require 'multi_json' require 'keen/aes_helper' module Keen class ScopedKey include AESHelper extend AESHelper attr_accessor :api_key attr_accessor :data class << self def decrypt!(api_key, scoped_key) encrypted = unhexlify(scoped_key) padded_api_key = pad(api_key) decrypted = aes256_decrypt(padded_api_key, encrypted) data = MultiJson.load(decrypted) self.new(api_key, data) end end def initialize(api_key, data) self.api_key = api_key self.data = data end def encrypt! json_str = MultiJson.dump(self.data) padded_api_key = pad(self.api_key) encrypted, iv = aes256_encrypt(padded_api_key, json_str) hexlify(iv) + hexlify(encrypted) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
keen-0.9.0 | lib/keen/scoped_key.rb |
keen-0.8.10 | lib/keen/scoped_key.rb |
keen-0.8.9 | lib/keen/scoped_key.rb |