gutils

package
v0.0.0-...-3c0ec91 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Encode

func Base64Encode(data []byte) string

Base64Encode is a base64 wrapper to encode `data`

func DecodeHexString

func DecodeHexString(hexStr string) ([]byte, error)

DecodeHexString decodes `hexStr` hex encoded string, ex: `4141` -> [65 65]

func GetHammingDistance

func GetHammingDistance(str1, str2 []byte) uint64

GetHammingDistance compute Hamming distance between 2 strings at bit level Example: `this is a test` and `wokka wokka!!!` has `37` as Hamming distance https://en.wikipedia.org/wiki/Hamming_distance

func GetMin

func GetMin(a, b int) int

func GetNrandBytes

func GetNrandBytes(n uint) ([]byte, error)

func GetPkcs7Padded

func GetPkcs7Padded(input []byte, blockLength int) []byte

func GetPkcs7Unpadded

func GetPkcs7Unpadded(input []byte, blockLength int) []byte

func GetSingleByteXor

func GetSingleByteXor(data []byte) (byte, error)

GetSingleByteXor attempts to obtain the single by XOR key Encrypted buffer is in `data`. Key is determined base on the heuristic that the original buffer is an english plaintext.

func IsAlpha

func IsAlpha(data []byte) bool

IsAlpha return true if all elements in `data` are >= 0x20 and <= 0x7e and not LF

func Memset

func Memset(buff []byte, v byte)

func SingleByteXor

func SingleByteXor(data []byte) ([]byte, error)

func SumFrequencies

func SumFrequencies(data []byte) float64

SumFrequencies sums letter frequencies for bytes in [A..Z ] https://en.wikipedia.org/wiki/Letter_frequency

func XorBytes

func XorBytes(data, key []byte) []byte

XorBytes xors `data` and `key` buffers. Returns a new buffer. if `len(data)` or `len(key)` is 0, return `data`

Types

This section is empty.

Jump to

Keyboard shortcuts

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