Documentation ¶
Index ¶
- Variables
- func KeyedAlphabet(key, alphabet string) string
- func KeyedAlphabetRange(key string, min, max rune) string
- func MorseFormatBullets(morse string) string
- func MorseFormatSpoken(morse string) string
- func RandomKey(length int) (string, error)
- func RemoveDuplicates(text string) string
- func RemovePunctuation(text string) string
- func RestorePunctuation(original, modified string) (string, error)
- func VigenereCrack(cipher string, keyLen int) []int8
- type Affine
- type CaesarKeyed
- type FracMorse
- type Morse
- type MorseAlphabet
- type OTP
- type Polybius
- type RC4
- type RC4A
- type ROT
- type ROTRange
- type Railfence
- type Trithemius
- type Vigenere
Constants ¶
This section is empty.
Variables ¶
var Atbash = Affine{25, -1, 25}
Atbash is the Atbash symmetric cipher.
var ROT13 = Affine{1, 13, 1}
ROT13 is the ROT-13 symmetric cipher. For example, "ABCDEFGHIJKLM" becomes "NOPQRSTUVWXYZ".
var ROT18 = rot18{}
ROT18 is the ROT-18 symmetric cipher. For example, "ABCXYZ012" becomes "STUFGHijk"
var ROT47 = &ROTRange{47, '!', '~'}
ROT47 is the ROT-47 symmetric cipher. For example, "ABCabc" becomes "pqr234".
var ROT5 = &ROTRange{5, '0', '9'}
ROT5 is the ROT-5 symmetric cipher. For example, "1234567890" becomes "5678901234".
Functions ¶
func KeyedAlphabet ¶
KeyedAlphabet creates an alphabet starting with a keyword. e.g. "Hello, World!", "ABCDEFGHIJKLMNOPQRSTUVWXYZ" becomes "HELOWRDABCFGIJKMNPQSTUVXYZ"
func KeyedAlphabetRange ¶
KeyedAlphabetRange creates an alphabet in a range of chars starting with a keyword. Uppercase and lowercase are considered different characters. e.g. "HELLO, WORLD!", 'A', 'Z' becomes "HELOWRDABCFGIJKMNPQSTUVXYZ"
func MorseFormatBullets ¶
MorseFormatBullets replaces the .- characters in Morse text with •– so the characters are vertially centered.
func MorseFormatSpoken ¶
MorseFormatSpoken replaces dots and dashes with dits and dahs in Morse text. https://en.wikipedia.org/wiki/Morse_code#Spoken_representation
func RemoveDuplicates ¶
func RemovePunctuation ¶
RemovePunctuation removes any non alphabetic chars from a string.
func RestorePunctuation ¶
RestorePunctuation - If punctuation was accidently removed, use this function to restore it. Requires the original string with punctuation.
func VigenereCrack ¶
VigenereCrack finds the key with the letter frequencies closest to English.
Types ¶
type Affine ¶
type Affine struct {
A, B, AInv int
}
Affine is a key for an Affine cipher
func NewAffine ¶
NewAffine creates an Affine. For a one-to-one mapping, a must be invertable, as in gcd(a, 26) == 1.
type CaesarKeyed ¶
type CaesarKeyed struct {
// contains filtered or unexported fields
}
func NewCaesarKeyed ¶
func NewCaesarKeyed(key string, shift int) *CaesarKeyed
func (*CaesarKeyed) Decipher ¶
func (c *CaesarKeyed) Decipher(text string) string
Decipher deciphers string using keyed Caesar cipher according to key.
func (*CaesarKeyed) Encipher ¶
func (c *CaesarKeyed) Encipher(text string) string
Encipher enciphers string using keyed Caesar cipher according to key.
type FracMorse ¶
type FracMorse struct {
// contains filtered or unexported fields
}
func NewFracMorse ¶
type Morse ¶
type Morse struct {
// contains filtered or unexported fields
}
func NewMorse ¶
func NewMorse(alphabets ...MorseAlphabet) *Morse
type MorseAlphabet ¶
type MorseAlphabet uint
const ( MorseInternational MorseAlphabet = iota MorseSymbols MorseProsigns MorseProsignsMultiLine MorseAbbrNumbers MorseAbbrNumbers2 MorseNonEnglish MorseGreek MorseRussian MorseBulgarian MorseHebrew MorseArabic MorsePersian Wabun //SKATS MorseThai )
type OTP ¶
type OTP struct {
// contains filtered or unexported fields
}
type Polybius ¶
type Polybius struct {
// contains filtered or unexported fields
}
type RC4 ¶
type RC4 struct {
// contains filtered or unexported fields
}
RC4 is an instance of the RC4 cipher.
type RC4A ¶
type RC4A struct {
// contains filtered or unexported fields
}
RC4A is an instance of the RC4A cipher, a variant of RC4 proposed by Souradyuti Paul and Bart Preneel.
type ROT ¶
type ROT struct {
// contains filtered or unexported fields
}
type ROTRange ¶
type ROTRange struct {
// contains filtered or unexported fields
}
func NewROTRange ¶
type Railfence ¶
type Railfence struct {
// contains filtered or unexported fields
}
RailfenceKey is a key for a Rail-fence cipher
func NewRailfence ¶
NewRailfence creates a Railfence.
type Trithemius ¶
type Trithemius struct{}
func NewTrithemius ¶
func NewTrithemius() *Trithemius
func (*Trithemius) Decipher ¶
func (t *Trithemius) Decipher(text string) string
Decipher deciphers string using Trithemius cipher.
func (*Trithemius) Encipher ¶
func (t *Trithemius) Encipher(text string) string
Encipher enciphers string using Trithemius cipher.