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
module Uu58 | |
# 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. | |
def self.uuid_to_base58(uuid, alphabet = SecureRandom::BASE58_ALPHABET) | |
ary = uuid.delete("-").to_i(16).digits(58).reverse | |
ary.unshift(0) while ary.length < 22 |
OlderNewer