codec

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package codec contains some type conversion functions, e.g. Bytes to Base64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base32ToBytes

func Base32ToBytes(input string) ([]byte, error)

Base32ToBytes converts base32 string to byte array

func Base64ToBigInt

func Base64ToBigInt(input string) (*big.Int, error)

Base64ToBigInt converts base64 string to big Int

func Base64ToBytes

func Base64ToBytes(input string) ([]byte, error)

Base64ToBytes converts base64 string to byte array

func Base64URLToBytes

func Base64URLToBytes(input string) ([]byte, error)

Base64URLToBytes converts base64URL string to byte array

func HexToBigInt

func HexToBigInt(input string) (*big.Int, error)

HexToBigInt converts hex string to big Int

func HexToBytes

func HexToBytes(input string) ([]byte, error)

HexToBytes converts hex string to byte array

Types

type ByteArray

type ByteArray []byte

ByteArray defines a byte arry

func GetHash

func GetHash(hashType HashType, input ...[]byte) ByteArray

GetHash returns the hash of the input given the hash type.

func ToByteArray

func ToByteArray(input ...[]byte) ByteArray

ToByteArray return the combined byte array for the input byte arrays.

func (ByteArray) Base32

func (o ByteArray) Base32() string

Base32 returns the base32 encoded string of the byte array

func (ByteArray) Base64

func (o ByteArray) Base64() string

Base64 returns the base64 encoded string of the byte array

func (ByteArray) Base64URL

func (o ByteArray) Base64URL() string

Base64URL returns the base64 URL encoded string of the byte array

func (ByteArray) BigInt

func (o ByteArray) BigInt() *big.Int

BigInt returns big integer the byte array represents

func (ByteArray) Bytes

func (o ByteArray) Bytes() []byte

Bytes gets the []byte

func (ByteArray) Hex

func (o ByteArray) Hex() string

Hex returns the hex encoded string of the byte array

type HashType

type HashType int

HashType defines the supported hash type, currently support md5, sha1, sha256 and sha512

const (
	MD5 HashType = iota
	SHA1
	SHA256
	SHA512
)

Enum the HashType

Jump to

Keyboard shortcuts

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