Sha256: 5afdf35d16d8b32a59aa99b3f34886766c2d1099c4945d51d926d48322618cdc

Contents?: true

Size: 1.27 KB

Versions: 28

Compression:

Stored size: 1.27 KB

Contents

require "digest/sha2"

module Sorcery
  # The activate_sorcery method has a custom_crypto_provider configuration option. 
  # This allows you to use any type of encryption you like.
  # Just create a class with a class level encrypt and matches? method. See example below.
  #
  # === Example
  #
  #   class MyAwesomeEncryptionMethod
  #     def self.encrypt(*tokens)
  #       # the tokens passed will be an array of objects, what type of object is irrelevant,
  #       # just do what you need to do with them and return a single encrypted string.
  #       # for example, you will most likely join all of the objects into a single string and then encrypt that string
  #     end
  #
  #     def self.matches?(crypted, *tokens)
  #       # return true if the crypted string matches the tokens.
  #       # depending on your algorithm you might decrypt the string then compare it to the token, or you might
  #       # encrypt the tokens and make sure it matches the crypted string, its up to you
  #     end
  #   end
  module CryptoProviders
    # = Sha256
    #
    # Uses the Sha256 hash algorithm to encrypt passwords.
    class SHA256
      include Common
      class << self
        def secure_digest(digest)
          Digest::SHA256.hexdigest(digest)
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
sorcery-0.9.1 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.9.0 lib/sorcery/crypto_providers/sha256.rb
cbsorcery-0.8.6 lib/sorcery/crypto_providers/sha256.rb
cb-sorcery-0.8.6 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.8.6 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.8.5 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.8.4 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.8.2 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.8.1 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.8.0 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.13 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.12 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.11 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.10 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.9 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.8 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.7 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.6 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.5 lib/sorcery/crypto_providers/sha256.rb
sorcery-0.7.4 lib/sorcery/crypto_providers/sha256.rb