cryptanalysis

package module
v0.0.0-...-e3bf4aa Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2017 License: BSD-3-Clause Imports: 8 Imported by: 0

README

cryptanalysis

Go package to perform common cryptanalysis functions.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChiAlpha = AlphabetFrequency{
	Alphabet: "abcdefghijklmnopqrstuvwxyz",
	Frequency: map[rune]float64{
		'a': 0.08167, 'b': 0.01492, 'c': 0.02782, 'd': 0.04253, 'e': 0.12702,
		'f': 0.02228, 'g': 0.02015, 'h': 0.06094, 'i': 0.06966, 'j': 0.00153,
		'k': 0.00772, 'l': 0.04025, 'm': 0.02406, 'n': 0.06749, 'o': 0.07507,
		'p': 0.01929, 'q': 0.00095, 'r': 0.05987, 's': 0.06327, 't': 0.09056,
		'u': 0.02758, 'v': 0.00978, 'w': 0.02360, 'x': 0.00150, 'y': 0.01974,
		'z': 0.00074},
}
View Source
var ChiAlphaSpace = AlphabetFrequency{
	Alphabet: "abcdefghijklmnopqrstuvwxyz ",
	Frequency: map[rune]float64{
		'a': 0.08167, 'b': 0.01492, 'c': 0.02782, 'd': 0.04253, 'e': 0.12702,
		'f': 0.02228, 'g': 0.02015, 'h': 0.06094, 'i': 0.06966, 'j': 0.00153,
		'k': 0.00772, 'l': 0.04025, 'm': 0.02406, 'n': 0.06749, 'o': 0.07507,
		'p': 0.01929, 'q': 0.00095, 'r': 0.05987, 's': 0.06327, 't': 0.09056,
		'u': 0.02758, 'v': 0.00978, 'w': 0.02360, 'x': 0.00150, 'y': 0.01974,
		'z': 0.00074, ' ': 0.23200},
}

Functions

func BreakCaesarShift

func BreakCaesarShift(cipher string, chi AlphabetFrequency) (float64, int, string)

func BreakSingleByteXor

func BreakSingleByteXor(data []byte, chi AlphabetFrequency) (float64, byte, string)

func BytesToInt

func BytesToInt(array []byte) (uint64, error)

func CaesarShift

func CaesarShift(data string, shift int) string

func Chunk

func Chunk(data []byte, size int) [][]byte

func DecodeB64Str

func DecodeB64Str(data string) []byte

func DecodeHexStr

func DecodeHexStr(data string) []byte

func DecryptCbc

func DecryptCbc(ciphertext, key, iv []byte) ([]byte, error)

func DecryptEcb

func DecryptEcb(ciphertext, key []byte) ([]byte, error)

func EncodeB64Str

func EncodeB64Str(data []byte) string

func EncodeHexStr

func EncodeHexStr(data []byte) string

func EncryptCbc

func EncryptCbc(plaintext, key, iv []byte) ([]byte, error)

func EncryptEcb

func EncryptEcb(plaintext, key []byte) ([]byte, error)

func EncryptXor

func EncryptXor(plain, key []byte) []byte

func Hamming

func Hamming(s1, s2 []byte) (int, error)

func KeyLength

func KeyLength(data []byte) (int, error)

func PadPkcs7

func PadPkcs7(data []byte, block_size int) []byte

func RandomBytes

func RandomBytes(size int) ([]byte, error)

func RandomIntRange

func RandomIntRange(start, end uint64) (uint64, error)

Return a random integer in the range [start, end)

func ScoreAlphabet

func ScoreAlphabet(data string, chi AlphabetFrequency) float64

func ScoreEcb

func ScoreEcb(data []byte, block_size int) float64

func Transpose

func Transpose(data [][]byte) [][]byte

func XorArrayByte

func XorArrayByte(b1 []byte, b2 byte) []byte

func XorArrays

func XorArrays(b1, b2 []byte) ([]byte, error)

func XorBytes

func XorBytes(b1, b2 byte) byte

Types

type AlphabetFrequency

type AlphabetFrequency struct {
	Alphabet  string
	Frequency map[rune]float64
}

Jump to

Keyboard shortcuts

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