Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HammingDistance ¶
HammingDistance computes the hamming distance (number of bits that are different) between b1 and b2.
func HexReaderToBytes ¶
HexReaderToBytes converts all hexadecimal-encoded data in r to raw bytes. The input has to consist of (possibly whitespace-separated) hexadecimal daat only - for example a file with some hexa data per line (newline separated). The returned byte buffer is the concatenation of all input found in the reader.
func HexToBytes ¶
HexToBytes converts hexadecimal encoded bytes to raw bytes, failing the program in case of errors. For example, []byte{"aa18"} is converted to []byte{0xaa, 0x18}.
func KLDivergence ¶
KLDivergence computes the Kullback-Leibler divergence between two probability distributions p and q. p and q are expected to have the same length and contain numbers that sum up to 1.0; The KL divergence is close to 0 if the two distributions are deemed "similar" and gets larger the more different they are. See https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence
func XorBytes ¶
XorBytes performs a binary XOR between two byte slices of the same length. If the length is different it fails. Returns a new byte slice with the result.
func XorBytesWithVal ¶
XorBytesWithVal performs a binary XOR between every byte in bs with b. Returns a new byte slice with the result.
func XorWithRepeatingMask ¶
XorWithRepeatingMask performs a binary XOR between bs and mask, with mask repeated enough times to cover the length of bs. For example, with a 10-byte bs and the mask "XYZ", bs will be XOR-ed with "XYZXYZXYZX". Note that just enough of the mask is taken to cover the leftovers.
Types ¶
This section is empty.