Documentation ¶
Overview ¶
Package vpsum contains checksum helpers.
Index ¶
- Constants
- func BufToInt128(checksum []byte) (*big.Int, error)
- func BufToInt256(checksum []byte) (*big.Int, error)
- func BufToInt32(checksum []byte) (uint32, error)
- func BufToInt512(checksum []byte) (*big.Int, error)
- func BufToInt64(checksum []byte) (uint64, error)
- func BufToStr128(checksum []byte) string
- func BufToStr256(checksum []byte) string
- func BufToStr32(checksum []byte) string
- func BufToStr512(checksum []byte) string
- func BufToStr64(checksum []byte) string
- func Checksum128(data []byte) []byte
- func Checksum256(data []byte) []byte
- func Checksum32(data []byte) []byte
- func Checksum512(data []byte) []byte
- func Checksum64(data []byte) []byte
- func IntToBuf128(checksum *big.Int) []byte
- func IntToBuf256(checksum *big.Int) []byte
- func IntToBuf32(checksum uint32) []byte
- func IntToBuf512(checksum *big.Int) []byte
- func IntToBuf64(checksum uint64) []byte
- func IntToStr128(checksum *big.Int) string
- func IntToStr256(checksum *big.Int) string
- func IntToStr32(checksum uint32) string
- func IntToStr512(checksum *big.Int) string
- func IntToStr64(checksum uint64) string
- func PseudoRand128(seed []byte, n *big.Int) *big.Int
- func PseudoRand256(seed []byte, n *big.Int) *big.Int
- func PseudoRand32(seed, n uint32) uint32
- func PseudoRand512(seed []byte, n *big.Int) *big.Int
- func PseudoRand64(seed, n uint64) uint64
- func StrToBuf128(checksum string) ([]byte, error)
- func StrToBuf256(checksum string) ([]byte, error)
- func StrToBuf32(checksum string) ([]byte, error)
- func StrToBuf512(checksum string) ([]byte, error)
- func StrToBuf64(checksum string) ([]byte, error)
- func StrToInt128(checksum string) (*big.Int, error)
- func StrToInt256(checksum string) (*big.Int, error)
- func StrToInt32(checksum string) (uint32, error)
- func StrToInt512(checksum string) (*big.Int, error)
- func StrToInt64(checksum string) (uint64, error)
Constants ¶
const PackageCopyright = "Copyright (C) 2015, 2016 Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh
PackageCopyright contains a short copyright notice.
const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh
PackageEmail contains a contact email for the package.
const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh
PackageLicense contains a short license information.
const PackageName = "Vapor Toolkit" // PackageName set by version.sh
PackageName contains a readable name of the package, suitable for display.
const PackageTarname = "vapor" // PackageTarname set by version.sh
PackageTarname contains a short name of the package, suitable for a filename.
const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh
PackageURL contains the address of the project homepage.
const VersionMajor = 0 // VersionMajor set by version.sh
VersionMajor is the project major version.
const VersionMinor = 3 // VersionMinor set by version.sh
VersionMinor is the project minor version.
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 ¶
BufToInt128 converts a 128 bits buffer to an integer. Buffer must be exactly 16 bytes, else it will fail.
func BufToInt256 ¶
BufToInt256 converts a 256 bits buffer to an integer. Buffer must be exactly 32 bytes, else it will fail.
func BufToInt32 ¶
BufToInt32 converts a 32 bits buffer to an integer. Buffer must be exactly 4 bytes, else it will fail.
func BufToInt512 ¶
BufToInt512 converts a 512 bits buffer to an integer. Buffer must be exactly 64 bytes, else it will fail.
func BufToInt64 ¶
BufToInt64 converts a 64 bits buffer to an integer. Buffer must be exactly 8 bytes, else it will fail.
func BufToStr128 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.