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

Documentation: Imrpove docs for Base. #6

Open
cognivore opened this issue Dec 26, 2022 · 0 comments
Open

Documentation: Imrpove docs for Base. #6

cognivore opened this issue Dec 26, 2022 · 0 comments

Comments

@cognivore
Copy link
Contributor

I wrote something. Should add it to the repo:

@doc """
  Offensive best-effort constructor.
  You really sholdn't use this stuff because it will run Base.decode functions until one of them succeeds.
  This may not be what you want.

  Base.decode functions have the following argument:
    - `encoded` - a string to decode
    - `alphabet` - a string of characters to use as alphabet
    - `padding` - a boolean flag indicating whether to use padding or not
  `encoded` is the only required argument. It is a string to decode. For example:
  iex> Base.decode64("0L/Ri9GJIG9sb2xvINGPINCy0L7QtNC40YLQtdC70Ywg0J3Qm9CeIQ==")
  "пыщ ololo я водитель НЛО!"

  If you're interested in going the other way, check out raw_to_urlsafe and binary_to_urlsafe functions, which use Base.encode.

  We don't have default encodings for anything but b64 urlsafe.

  To unwrap `Uptight.Base` structures into a raw binary, access field `.raw`.
  To unwrap `Uptight.Base` structures into a base64 urlsafe encoded string, access field `.encoded`.
  """
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