Skip to content

Instantly share code, notes, and snippets.

View inopinatus's full-sized avatar
🐼
fuzzy logic

Josh Goodall inopinatus

🐼
fuzzy logic
View GitHub Profile
@inopinatus
inopinatus / uu58.rb
Last active May 3, 2025 13:41
Convert UUIDs to/from base58
module Uu58
ALPHABET58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".chars.freeze
ALPHAMAP58 = ALPHABET58.each_with_index.to_h.freeze
# Convert a string UUID to a base58 string representation.
#
# Output will be padded up to 22 digits if necessary.
#
# Behaviour is undefined if passing something other than a 128-bit
# hex string in network order with optional interstitial hyphens.