base57.go
func (b *base57) stringToNum(s string) (string, error) {
	n := big.NewInt(0)

	for i := len(s) - 1; i >= 0; i-- {
		n.Mul(n, big.NewInt(b.alphabet.Length()))

		index, err := b.alphabet.Index(string(s[i]))
		if err != nil {
			return "", err
		}

		n.Add(n, big.NewInt(index))
	}

	x := fmt.Sprintf("%x", n)

	if len(x) < 32 {
		// Pad the most significant bit (MSG) with 0 (zero) if the string is too short.
		x = strings.Repeat("0", 32-len(x)) + x
	} else if len(x) > 32 {
		return "", fmt.Errorf("UUID length overflow for %q", s)
	}

	return fmt.Sprintf("%s-%s-%s-%s-%s", x[0:8], x[8:12], x[12:16], x[16:20], x[20:32]), nil
}
func (b *base57) stringToNum(s string) (string, error) {
	n := big.NewInt(0)

	for i := len(s) - 1; i >= 0; i-- {
		n.Mul(n, big.NewInt(b.alphabet.Length()))

		index, err := b.alphabet.Index(string(s[i]))
		if err != nil {
			return "", err
		}

		n.Add(n, big.NewInt(index))
	}

	x := fmt.Sprintf("%x", n)

	if len(x) < 32 {
		// Pad the most significant bit (MSG) with 0 (zero) if the string is too short.
		x = strings.Repeat("0", 32-len(x)) + x
	} else if len(x) > 32 {
		return "", fmt.Errorf("UUID length overflow for %q", s)
	}

	return fmt.Sprintf("%s-%s-%s-%s-%s", x[0:8], x[8:12], x[12:16], x[16:20], x[20:32]), nil
}
// stringToNum converts a string a number using the given alpabet.