Skip to content

Instantly share code, notes, and snippets.

@DavidMellul
Last active February 26, 2018 01:12
Show Gist options
  • Save DavidMellul/ecfe37e98119e38b522949288e207c1b to your computer and use it in GitHub Desktop.
Save DavidMellul/ecfe37e98119e38b522949288e207c1b to your computer and use it in GitHub Desktop.
def generate_random_uid
# Generate a random value between 0 and 1 000 000
base_pseudo_random_value = rand(1_000_000)
uid = evil_maths(base_pseudo_random_value)
return uid
end
if first_launch?
uid = generate_random_uid()
store_in_secret_place(uid)
# Imagine we have two columns like so : |license|uid|.
# At the beginning the license is not associated to any uid.
# activate_in_database will just associate the license number to the computer UID
# Something like : UPDATE Licenses set UID = :uid WHERE license_number = :license
activate_in_database(uid,license)
# => Start software
else
uid = retrieve_from_secret_place(uid)
if online_record_exists?(uid)
# => Start software
else
# => Show error message
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment