Sha256: 44a4a3d5fea60c8972de7917f01677ac34d8d28e9e52c39eff2cf36ee7b5e437
Contents?: true
Size: 852 Bytes
Versions: 10
Compression:
Stored size: 852 Bytes
Contents
# TITLE: # # Crypt # # SUMMARY: # # Adds a default salt to crypt. # # TODO: # # - Deprecate once/if part of Ruby proper. # class String alias_method :_crypt, :crypt # Common Unix cryptography 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 # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TestStringCrypt < Test::Unit::TestCase def test_crypt assert_nothing_raised { "abc 123".crypt } end def test_crypt! assert_nothing_raised { "abc 123".crypt! } end end =end
Version data entries
10 entries across 10 versions & 1 rubygems