Class: Faker::Crypto
Constant Summary collapse
- MD5_MIN_NUMBER_OF_CHARACTERS =
Setting the lorem character number lower than the default of 255 reduces the time complexity of each hash algorithm while still returning deterministically unique values. See github.com/faker-ruby/faker/pull/2938 for more info.
25
- SHA1_MIN_NUMBER_OF_CHARACTERS =
31
- SHA256_MIN_NUMBER_OF_CHARACTERS =
50
- SHA512_MIN_NUMBER_OF_CHARACTERS =
100
Constants inherited from Base
Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.md5 ⇒ String
Produces an MD5 hash.
-
.sha1 ⇒ String
Produces a SHA1 hash.
-
.sha256 ⇒ String
Produces a SHA256 hash.
-
.sha512 ⇒ String
Produces a SHA512 hash.
Methods inherited from Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale
Class Method Details
.md5 ⇒ String
Produces an MD5 hash.
26 27 28 |
# File 'lib/faker/default/crypto.rb', line 26 def md5 OpenSSL::Digest::MD5.hexdigest(Lorem.characters(number: MD5_MIN_NUMBER_OF_CHARACTERS)) end |
.sha1 ⇒ String
Produces a SHA1 hash.
39 40 41 |
# File 'lib/faker/default/crypto.rb', line 39 def sha1 OpenSSL::Digest::SHA1.hexdigest(Lorem.characters(number: SHA1_MIN_NUMBER_OF_CHARACTERS)) end |
.sha256 ⇒ String
Produces a SHA256 hash.
52 53 54 |
# File 'lib/faker/default/crypto.rb', line 52 def sha256 OpenSSL::Digest::SHA256.hexdigest(Lorem.characters(number: SHA256_MIN_NUMBER_OF_CHARACTERS)) end |
.sha512 ⇒ String
Produces a SHA512 hash.
65 66 67 |
# File 'lib/faker/default/crypto.rb', line 65 def sha512 OpenSSL::Digest::SHA512.hexdigest(Lorem.characters(number: SHA512_MIN_NUMBER_OF_CHARACTERS)) end |