vpsum

package
v0.0.0-...-bf055c7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package vpsum contains checksum helpers.

Index

Constants

View Source
const PackageCopyright = "Copyright (C)  2015, 2016  Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh

PackageCopyright contains a short copyright notice.

View Source
const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh

PackageEmail contains a contact email for the package.

View Source
const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh

PackageLicense contains a short license information.

View Source
const PackageName = "Vapor Toolkit" // PackageName set by version.sh

PackageName contains a readable name of the package, suitable for display.

View Source
const PackageTarname = "vapor" // PackageTarname set by version.sh

PackageTarname contains a short name of the package, suitable for a filename.

View Source
const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh

PackageURL contains the address of the project homepage.

View Source
const VersionMajor = 0 // VersionMajor set by version.sh

VersionMajor is the project major version.

View Source
const VersionMinor = 3 // VersionMinor set by version.sh

VersionMinor is the project minor version.

View Source
const VersionStamp = "c6a4298" // VersionStamp set by version.sh

VersionStamp is the project stamp, possibly changes for each build.

Variables

This section is empty.

Functions

func BufToInt128

func BufToInt128(checksum []byte) (*big.Int, error)

BufToInt128 converts a 128 bits buffer to an integer. Buffer must be exactly 16 bytes, else it will fail.

func BufToInt256

func BufToInt256(checksum []byte) (*big.Int, error)

BufToInt256 converts a 256 bits buffer to an integer. Buffer must be exactly 32 bytes, else it will fail.

func BufToInt32

func BufToInt32(checksum []byte) (uint32, error)

BufToInt32 converts a 32 bits buffer to an integer. Buffer must be exactly 4 bytes, else it will fail.

func BufToInt512

func BufToInt512(checksum []byte) (*big.Int, error)

BufToInt512 converts a 512 bits buffer to an integer. Buffer must be exactly 64 bytes, else it will fail.

func BufToInt64

func BufToInt64(checksum []byte) (uint64, error)

BufToInt64 converts a 64 bits buffer to an integer. Buffer must be exactly 8 bytes, else it will fail.

func BufToStr128

func BufToStr128(checksum []byte) string

BufToStr128 converts a 128 bits buffer to a checksum string. If the buffer does not have the right size (16 bytes), the string is truncated or padded with heading zeroes. So the result is always a 32 bytes/runes string.

func BufToStr256

func BufToStr256(checksum []byte) string

BufToStr256 converts a 256 bits buffer to a checksum string. If the buffer does not have the right size (32 bytes), the string is truncated or padded with heading zeroes. So the result is always a 64 bytes/runes string.

func BufToStr32

func BufToStr32(checksum []byte) string

BufToStr32 converts a 32 bits buffer to a checksum string. If the buffer does not have the right size (4 bytes), the string is truncated or padded with heading zeroes. So the result is always an 8 bytes/runes string.

func BufToStr512

func BufToStr512(checksum []byte) string

BufToStr512 converts a 512 bits buffer to a checksum string. If the buffer does not have the right size (64 bytes), the string is truncated or padded with heading zeroes. So the result is always a 128 bytes/runes string.

func BufToStr64

func BufToStr64(checksum []byte) string

BufToStr64 converts a 64 bits buffer to a checksum string. If the buffer does not have the right size (8 bytes), the string is truncated or padded with heading zeroes. So the result is always a 16 bytes/runes string.

func Checksum128

func Checksum128(data []byte) []byte

Checksum128 calculates a 128 bits checksum of data. Internally, uses some cryptographic method such as SHA, but don't rely on this, just consider it's a checksum.

func Checksum256

func Checksum256(data []byte) []byte

Checksum256 calculates a 256 bits checksum of data. Internally, uses some cryptographic method such as SHA, but don't rely on this, just consider it's a checksum.

func Checksum32

func Checksum32(data []byte) []byte

Checksum32 calculates a 32 bits checksum of data. Internally, uses some cryptographic method such as MD5, but don't rely on this, just consider it's a checksum.

func Checksum512

func Checksum512(data []byte) []byte

Checksum512 calculates a 512 bits checksum of data. Internally, uses some cryptographic method such as SHA, but don't rely on this, just consider it's a checksum.

func Checksum64

func Checksum64(data []byte) []byte

Checksum64 calculates a 64 bits checksum of data. Internally, uses some cryptographic method such as MD5, but don't rely on this, just consider it's a checksum.

func IntToBuf128

func IntToBuf128(checksum *big.Int) []byte

IntToBuf128 converts a 128 bits integer to a byte buffer. If the number is too low, the buffer is padded with heading zeroes. So the result is always a 16 bytes buffer.

func IntToBuf256

func IntToBuf256(checksum *big.Int) []byte

IntToBuf256 converts a 256 bits integer to a byte buffer. If the number is too low, the buffer is padded with heading zeroes. So the result is always a 32 bytes buffer.

func IntToBuf32

func IntToBuf32(checksum uint32) []byte

IntToBuf32 converts a 32 bits integer to a byte buffer. If the number is too low, the buffer is padded with heading zeroes. So the result is always a 4 bytes buffer.

func IntToBuf512

func IntToBuf512(checksum *big.Int) []byte

IntToBuf512 converts a 512 bits integer to a byte buffer. If the number is too low, the buffer is padded with heading zeroes. So the result is always a 64 bytes buffer.

func IntToBuf64

func IntToBuf64(checksum uint64) []byte

IntToBuf64 converts a 64 bits integer to a byte buffer. If the number is too low, the buffer is padded with heading zeroes. So the result is always an 8 bytes buffer.

func IntToStr128

func IntToStr128(checksum *big.Int) string

IntToStr128 converts a 128 bits integer to a string. It uses an hexadecimal representation of the number. If the number is too low, the string is padded with heading zeroes. So the result is always a 32 bytes/runes string.

func IntToStr256

func IntToStr256(checksum *big.Int) string

IntToStr256 converts a 256 bits integer to a string. It uses an hexadecimal representation of the number. If the number is too low, the string is padded with heading zeroes. So the result is always a 64 bytes/runes string.

func IntToStr32

func IntToStr32(checksum uint32) string

IntToStr32 converts a 32 bits integer to a string. It uses an hexadecimal representation of the number. If the number is too low, the string is padded with heading zeroes. So the result is always an 8 bytes/runes string.

func IntToStr512

func IntToStr512(checksum *big.Int) string

IntToStr512 converts a 512 bits integer to a string. It uses an hexadecimal representation of the number. If the number is too low, the string is padded with heading zeroes. So the result is always a 128 bytes/runes string.

func IntToStr64

func IntToStr64(checksum uint64) string

IntToStr64 converts a 64 bits integer to a string. It uses an hexadecimal representation of the number. If the number is too low, the string is padded with heading zeroes. So the result is always a 16 bytes/runes string.

func PseudoRand128

func PseudoRand128(seed []byte, n *big.Int) *big.Int

PseudoRand128 returns a pseudo-random value on 128 bits. It is totally predictable, using seed as a input. Called with a given seed, always returns the same result. If n is nil or 0, returns a number between [0, 2^128). If n is greater than 0, returns a number between [0, n).

func PseudoRand256

func PseudoRand256(seed []byte, n *big.Int) *big.Int

PseudoRand256 returns a pseudo-random value on 256 bits. It is totally predictable, using seed as a input. Called with a given seed, always returns the same result. If n is nil or 0, returns a number between [0, 2^256). If n is greater than 0, returns a number between [0, n).

func PseudoRand32

func PseudoRand32(seed, n uint32) uint32

PseudoRand32 returns a pseudo-random value on 32 bits. It is totally predictable, using seed as a input. Called with a given seed, always returns the same result. If n is nil or 0, returns a number between [0, 2^32). If n is greater than 0, returns a number between [0, n).

func PseudoRand512

func PseudoRand512(seed []byte, n *big.Int) *big.Int

PseudoRand512 returns a pseudo-random value on 512 bits. It is totally predictable, using seed as a input. Called with a given seed, always returns the same result. If n is nil or 0, returns a number between [0, 2^512). If n is greater than 0, returns a number between [0, n).

func PseudoRand64

func PseudoRand64(seed, n uint64) uint64

PseudoRand64 returns a pseudo-random value on 64 bits. It is totally predictable, using seed as a input. Called with a given seed, always returns the same result. If n is nil or 0, returns a number between [0, 2^64). If n is greater than 0, returns a number between [0, n).

func StrToBuf128

func StrToBuf128(checksum string) ([]byte, error)

StrToBuf128 converts a 128 bits checksum string to a buffer. The string must be exactly 32 bytes/runes long and be readable as an hexadecimal number, else it will fail. The result buffer is twice shorter (16 bytes).

func StrToBuf256

func StrToBuf256(checksum string) ([]byte, error)

StrToBuf256 converts a 256 bits checksum string to a buffer. The string must be exactly 64 bytes/runes long and be readable as an hexadecimal number, else it will fail. The result buffer is twice shorter (32 bytes).

func StrToBuf32

func StrToBuf32(checksum string) ([]byte, error)

StrToBuf32 converts a 32 bits checksum string to a buffer. The string must be exactly 8 bytes/runes long and be readable as an hexadecimal number, else it will fail. The result buffer is twice shorter (4 bytes).

func StrToBuf512

func StrToBuf512(checksum string) ([]byte, error)

StrToBuf512 converts a 512 bits checksum string to a buffer. The string must be exactly 128 bytes/runes long and be readable as an hexadecimal number, else it will fail. The result buffer is twice shorter (64 bytes).

func StrToBuf64

func StrToBuf64(checksum string) ([]byte, error)

StrToBuf64 converts a 64 bits checksum string to a buffer. The string must be exactly 16 bytes/runes long and be readable as an hexadecimal number, else it will fail. The result buffer is twice shorter (8 bytes).

func StrToInt128

func StrToInt128(checksum string) (*big.Int, error)

StrToInt128 converts a 128 bits checksum string to an integer. The string must be exactly 32 bytes/runes long and be readable as an hexadecimal number, else it will fail.

func StrToInt256

func StrToInt256(checksum string) (*big.Int, error)

StrToInt256 converts a 256 bits checksum string to an integer. The string must be exactly 64 bytes/runes long and be readable as an hexadecimal number, else it will fail.

func StrToInt32

func StrToInt32(checksum string) (uint32, error)

StrToInt32 converts a 32 bits checksum string to an integer. The string must be exactly 8 bytes/runes long and be readable as an hexadecimal number, else it will fail.

func StrToInt512

func StrToInt512(checksum string) (*big.Int, error)

StrToInt512 converts a 512 bits checksum string to an integer. The string must be exactly 128 bytes/runes long and be readable as an hexadecimal number, else it will fail.

func StrToInt64

func StrToInt64(checksum string) (uint64, error)

StrToInt64 converts a 64 bits checksum string to an integer. The string must be exactly 16 bytes/runes long and be readable as an hexadecimal number, else it will fail.

Types

This section is empty.

Jump to

Keyboard shortcuts

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