nixbase32

package
v0.0.0-...-93cb24a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 2 Imported by: 8

Documentation

Overview

Package nixbase32 implements the slightly odd "base32" encoding that's used in Nix.

Nix uses a custom alphabet. Contrary to other implementations (RFC4648), encoding to "nix base32" also reads in characters in reverse order (and doesn't use any padding), which makes adopting encoding/base32 hard.

Index

Constants

View Source
const Alphabet = "0123456789abcdfghijklmnpqrsvwxyz"

Alphabet contains the list of valid characters for the Nix base32 Alphabet.

Variables

This section is empty.

Functions

func Decode

func Decode(dst, src []byte) (n int, err error)

Decode decodes src using nixbase32. It writes at most DecodedLen of len(src) bytes to dst and returns the number of bytes written.

func DecodeString

func DecodeString(s string) ([]byte, error)

DecodeString returns the bytes represented by the nixbase32 string s or returns an error.

func DecodedLen

func DecodedLen(n int) int

DecodedLen returns the length in bytes of the decoded data corresponding to n bytes of base32-encoded data. If we have bits that don't fit into here, they are padding and must be 0.

func Encode

func Encode(dst, src []byte)

Encode encodes src using nixbase32, writing EncodedLen of len(src) bytes to dst.

func EncodeToString

func EncodeToString(src []byte) string

EncodeToString returns the nixbase32 encoding of src.

func EncodedLen

func EncodedLen(n int) int

EncodedLen returns the length in bytes of the base32 encoding of an input buffer of length n.

func Is

func Is(c byte) bool

Is reports whether the given byte is part of the nixbase32 alphabet.

func ValidateString

func ValidateString(src string) error

ValidateString returns an error if s is not valid nixbase32.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL