From 878a06980c8de6d24c3cdb4ed8ee70b5ea611b8d Mon Sep 17 00:00:00 2001 From: derek mcquay Date: Fri, 11 Mar 2016 23:31:26 -0800 Subject: [PATCH] 100% golint --- psyfer/aes.go | 9 ++++++--- psyfer/substitution.go | 3 +++ psyfer/transposition.go | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/psyfer/aes.go b/psyfer/aes.go index 85c66de..065b64f 100644 --- a/psyfer/aes.go +++ b/psyfer/aes.go @@ -75,12 +75,13 @@ var rcon = []byte{0x00, // rcon[] is 1-based, so the first entry is just a place 0xE8, 0xCB, 0x8D, } -// renamed []byte type for simplicity +//Block renamed []byte type for simplicity type Block []byte var keyexpanded []Block var key Block +//ToString writes []Block to a string in ascii form func ToString(all []Block, keysize int, k Block, decrypt bool) string { final := "" for _, bl := range all { @@ -95,6 +96,7 @@ func ToString(all []Block, keysize int, k Block, decrypt bool) string { return final } +//ToHex writes []Block to a string in hex form func ToHex(all []Block, keysize int, k Block, decrypt bool) string { final := "" for _, bl := range all { @@ -111,6 +113,7 @@ func ToHex(all []Block, keysize int, k Block, decrypt bool) string { return final } +//BlockGen helps create []Block from incoming string func BlockGen(arg string) []Block { all := []Block{} b := Block{} @@ -131,7 +134,7 @@ func BlockGen(arg string) []Block { return all } -//performs AES cipher +//Cipher performs AES cipher func Cipher(cur Block, bit int, incomingKey Block) Block { if len(cur) != 16 { missing := 16 - len(cur) @@ -191,7 +194,7 @@ func Cipher(cur Block, bit int, incomingKey Block) Block { return cur } -//inverse AES cipher +//InvCipher inverse AES cipher func InvCipher(cur Block, bit int, incomingKey Block) Block { if len(cur) != 16 { missing := 16 - len(cur) diff --git a/psyfer/substitution.go b/psyfer/substitution.go index cb8b4f9..5706a37 100644 --- a/psyfer/substitution.go +++ b/psyfer/substitution.go @@ -6,12 +6,14 @@ import ( "log" ) +//KeyJSON is a letter to letter mapping key type KeyJSON struct { Key map[string]string `json:"key"` } var k = KeyJSON{} +//ReadConfig reads a json file containing key map func ReadConfig(file string) { dat, err := ioutil.ReadFile(file) if err != nil { @@ -21,6 +23,7 @@ func ReadConfig(file string) { k.Key[" "] = " " // keep spaces alive } +//Substitution performs Substitution cipher based on key func Substitution(input string) string { inputSlice := []string{} output := "" diff --git a/psyfer/transposition.go b/psyfer/transposition.go index 085fd98..8378e6e 100644 --- a/psyfer/transposition.go +++ b/psyfer/transposition.go @@ -2,6 +2,7 @@ package psyfer import "math/rand" +//TransposeRandom randomly transposes string func TransposeRandom(input string) string { shuffle := "" list := rand.Perm(len(input)) @@ -11,6 +12,7 @@ func TransposeRandom(input string) string { return shuffle } +//TransposeRailFence performs railfence transpose func TransposeRailFence(input string) string { rf := "" for i := 0; i < len(input); i += 2 { @@ -22,6 +24,7 @@ func TransposeRailFence(input string) string { return rf } +//TransposeSplit performs split transpose func TransposeSplit(input string) string { split := "" length := len(input) @@ -40,6 +43,7 @@ func TransposeSplit(input string) string { return split } +//DeTransposeRailFence performs inverse railfence func DeTransposeRailFence(input string) string { derf := "" length := len(input) @@ -58,6 +62,7 @@ func DeTransposeRailFence(input string) string { return derf } +//DeTransposeSplit performs inverse split func DeTransposeSplit(input string) string { desplit := "" if len(input)%2 == 0 {