utils

package
v0.0.0-...-d3da849 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64ToByteSlice

func Base64ToByteSlice(input string) []byte

Base64ToByteSlice base64 decodes input

func ByteSliceToBase64

func ByteSliceToBase64(buf []byte) string

ByteSliceToBase64 base64 encodes buf per https://www.rfc-editor.org/rfc/rfc4648

func ByteSliceToHex

func ByteSliceToHex(buf []byte) string

converts []byte to hex-encoded string.

func GetBit

func GetBit[T constraints.Unsigned, U constraints.Integer](v T, n U) T

func HexToByteSlice

func HexToByteSlice(s string) []byte

converts a hex string to []byte

func HmacSha1

func HmacSha1(key, msg []byte) []byte

See https://en.wikipedia.org/wiki/HMAC

func IsAdmin

func IsAdmin(message string) bool

Given a string of the form: key1=value1;key2=value2;... returns true if the first "admin" key is "true".

func NewSha1

func NewSha1() *sha1

func NewSha256

func NewSha256() *sha256

func Pad

func Pad(buf []byte, blockSize int) []byte

pad buffer using pkcs#7 the padding scheme is documented here: https://datatracker.ietf.org/doc/html/rfc2315#section-10.3

func PanicOnErr

func PanicOnErr(err error)

panic if err is set

func PrintTitle

func PrintTitle(set, challenge int)

print the set and challenge using ansi colors

func Randn

func Randn(n *big.Int) *big.Int

func Remaining

func Remaining(n, m int) int

returns the smallest non-negative x such that (n+x)%m equals 0.

func RotateLeft

func RotateLeft(v uint32, n int) uint32

func RotateRight

func RotateRight(v uint32, n int) uint32

func SetBit

func SetBit[T constraints.Unsigned, U constraints.Integer](a T, n U, v T) T

func Unpad

func Unpad(buf []byte, blockSize int) ([]byte, error)

assumes buffer is padded with pkcs#7 and strips the padding

func Xor

func Xor(buf1, buf2 []byte) []byte

returns new buffer with content set to buf1 xor buf2

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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