100% golint

This commit is contained in:
Derek McQuay 2016-03-11 23:31:26 -08:00
parent 5da34d3544
commit 878a06980c
3 changed files with 14 additions and 3 deletions

View File

@ -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)

View File

@ -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 := ""

View File

@ -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 {