Skip to content

Instantly share code, notes, and snippets.

@coderdan
Created April 3, 2023 04:20
Show Gist options
  • Save coderdan/4d0a2deae9289703d120515408f1ed98 to your computer and use it in GitHub Desktop.
Save coderdan/4d0a2deae9289703d120515408f1ed98 to your computer and use it in GitHub Desktop.
Example of using encrypted values as deterministic seeds for Faker
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