Class: Faker::Crypto

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/crypto.rb

Constant Summary

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.md5String

Produces an MD5 hash.

Examples:

Faker::Crypto.md5 #=> "6b5ed240042e8a65c55ddb826c3408e6"

Returns:

  • (String)

Available since:

  • 1.6.4


17
18
19
# File 'lib/faker/default/crypto.rb', line 17

def md5
  Digest::MD5.hexdigest(Lorem.characters)
end

.sha1String

Produces a SHA1 hash.

Examples:

Faker::Crypto.sha1 #=> "4e99e31c51eef8b2d290e709f757f92e558a503f"

Returns:

  • (String)

Available since:

  • 1.6.4


30
31
32
# File 'lib/faker/default/crypto.rb', line 30

def sha1
  Digest::SHA1.hexdigest(Lorem.characters)
end

.sha256String

Produces a SHA256 hash.

Examples:

Faker::Crypto.sha256 #=> "51e4dbb424cd9db1ec5fb989514f2a35652ececef33f21c8dd1fd61bb8e3929d"

Returns:

  • (String)

Available since:

  • 1.6.4


43
44
45
# File 'lib/faker/default/crypto.rb', line 43

def sha256
  Digest::SHA256.hexdigest(Lorem.characters)
end