Sha256: e11ff369cf38f826176709ef381b0fb743e8928e6cc748a9da69b89bf64602e5
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
require 'digest/sha1' module PluginAWeek #:nodoc: module EncryptedStrings #:nodoc: # Encrypts a string using a Secure Hash Algorithm (SHA), specifically SHA-1. class ShaEncryptor < Encryptor # The default salt value to use during encryption @@default_salt = 'salt' cattr_accessor :default_salt attr_accessor :salt # Configuration options: # * <tt>salt</tt> - Salt value to use for encryption def initialize(options = {}) options = options.symbolize_keys options.assert_valid_keys(:salt) options.reverse_merge!(:salt => @@default_salt) @salt = options[:salt] super() end # Decryption is not supported. def can_decrypt? false end # Returns the encrypted value of the data def encrypt(data) Digest::SHA1.hexdigest(data + @salt) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
encrypted_strings-0.0.1 | lib/encrypted_strings/sha_encryptor.rb |