module PassLock
PassLock
base module
Constants
- VERSION
The version of the gem installed.
Public Class Methods
Encodes password in Base64. @param pass [String] The password to be encoded @param layers [Fixnum] The amount of layering @return [String] Returns the Base64-encoded version of the password
# File lib/passlock.rb, line 46 def self.base64(pass, layers: 1) layers.times do pass = Base64.encode64 pass end pass end
Encodes password in Base64 encoded hash. @param pass [String] The password to be encoded @param layers [Fixnum] The amount of layering @return [String] The Base64-encoded hash
# File lib/passlock.rb, line 101 def self.base64hash(pass, layers: 1) layers.times do pass = Base64.encode64((HMAC::SHA1.new(pass) << 'base').digest).strip end pass end
A randomly generated passord. @param options [Array] Options for the password given in strings. Available strings ‘number` `upletter` `downletter` `symbol` @param length [Integer] How long the password will be @return [String] Returns the Base64-encoded version of the password.
# File lib/passlock.rb, line 22 def self.cpass(options, length) options = options != Array || options.empty? ? options : %w(number upletter downletter symbol) length = length.is_a?(Integer) && length > 0 ? length : 10 chars = [] result = '' options.each do |flag| chars.concat(@opts[flag].scan(/./)) unless @opts[flag].nil? end length.to_i.times do result += chars.sample end result end
Creats a SHA1 hash. @param pass [String] The password to be encoded @param layers [Fixnum] The amount of layering @return [String] The SHA1 hash
# File lib/passlock.rb, line 57 def self.sha1(pass, layers: 1) layers.times do pass = Digest::SHA1.hexdigest pass end pass end
Creats a SHA256 hash. @param pass [String] The password to be encoded @param layers [Fixnum] The amount of layering @return [String] The SHA256 hash
# File lib/passlock.rb, line 68 def self.sha256(pass, layers: 1) layers.times do pass = Digest::SHA256.new.update(pass).to_s end pass end
Creats a SHA384 hash. @param pass [String] The password to be encoded @param layers [Fixnum] The amount of layering @return [String] The SHA384 hash
# File lib/passlock.rb, line 79 def self.sha384(pass, layers: 1) layers.times do pass = Digest::SHA384.new.update(pass).to_s end pass end
Creats a SHA512 hash. @param pass [String] The password to be encoded @param layers [Fixnum] The amount of layering @return [String] The SHA512 hash
# File lib/passlock.rb, line 90 def self.sha512(pass, layers: 1) layers.times do pass = Digest::SHA512.new.update(pass).to_s end pass end
Creates a UUID. @return [String] The UUID
# File lib/passlock.rb, line 38 def self.uuid SecureRandom.uuid end