Sha256: 48f48eda93d445229274b28b4f295d78eefeb703584cb0c348a3e2bcab6d0860

Contents?: true

Size: 416 Bytes

Versions: 3

Compression:

Stored size: 416 Bytes

Contents

class String

  alias_method :_crypt, :crypt

  # Common Unix cryptography method.
  # This adds a default salt to the built-in crypt method.

  def crypt(salt=nil)
    salt ||= (
      (rand(26) + (rand(2) == 0 ? 65 : 97) ).chr +
      (rand(26) + (rand(2) == 0 ? 65 : 97) ).chr
    )
    _crypt(salt)
  end

  # Common Unix cryptography in-place method.

  def crypt!(salt=nil)
    replace(crypt(salt))
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-2.2.0 lib/core/facets/string/crypt.rb
facets-2.2.1 lib/core/facets/string/crypt.rb
facets-2.3.0 lib/core/facets/string/crypt.rb