lib/refcode.rb in refcode-0.0.1 vs lib/refcode.rb in refcode-0.1.0

- old
+ new

@@ -1,41 +1,7 @@ require 'uri' require 'yaml' require 'base64url' require 'encryptor' require 'refcode/version' - -module Refcode - - class Encoder - - attr_accessor :secret, :salt - - def initialize - yield self if block_given? - end - - def encode val - Base64URL.encode(encrypt(YAML.dump(val))) - end - - def decode val - YAML.load(decrypt(Base64URL.decode(val))) - end - - def encrypt val - Encryptor.encrypt(:value => val, :key => @secret, :salt => @salt, :iv => iv) - end - - def decrypt val - Encryptor.decrypt(:value => val, :key => @secret, :salt => @salt, :iv => iv) - end - - private - - def iv - [@secret, @salt].join - end - - end - -end +require 'refcode/encoder' +require 'refcode/encodable'