Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generate a random base58 string? #2

Open
zw963 opened this issue Oct 30, 2023 · 0 comments
Open

Support generate a random base58 string? #2

zw963 opened this issue Oct 30, 2023 · 0 comments

Comments

@zw963
Copy link

zw963 commented Oct 30, 2023

As describe by following naive code, thanks.

module Base58
  extend self

  VERSION = "0.1.0"

  ALPHABET = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ".chars

  def random(chars : Int32)
    String.build(chars) do |sb|
      chars.times { sb << ALPHABET.sample }
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant