Created
April 3, 2023 04:20
-
-
Save coderdan/4d0a2deae9289703d120515408f1ed98 to your computer and use it in GitHub Desktop.
Example of using encrypted values as deterministic seeds for Faker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'faker' | |
def fake_using(hex_str) | |
prev_random = Faker::Config.random | |
Faker::Config.random = Random.new(hex_str.to_i(16)) | |
result = yield | |
Faker::Config.random = prev_random | |
result | |
end | |
hex_str = "E0D7829DFF0298" | |
p fake_using(hex_str) { Faker::Name.name } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment