예제 #1
0
파일: base64.go 프로젝트: bonnefoa/crypto
func Base64Decode(src []byte) []byte {
	sublists := list.Sublist(src, 4)
	res := make([]byte, len(sublists)*3)
	for i, group := range sublists {
		subgroup := mergeGroupOfSix(group)
		copy(res[i*3:i*3+3], subgroup)
	}
	return res
}
예제 #2
0
파일: base64.go 프로젝트: bonnefoa/crypto
func Base64Encode(src []byte) []byte {
	sublists := list.Sublist(src, 3)
	res := make([]byte, len(sublists)*4)
	for i, group := range sublists {
		subgroup := groupBySix(group)
		copy(res[i*4:i*4+4], subgroup)
	}
	return res
}
예제 #3
0
파일: xor.go 프로젝트: bonnefoa/crypto
func GuessRepeatXor(size int, src []byte) XorCandidates {
	log.Printf("Trying key size %d \n", size)
	sublists := list.Sublist(src, size)
	blocks := TransposeBlocks(sublists)

	xorCandidates := make(XorCandidates, 0)
	xorBlocks := make([]XorCandidates, size)
	for i, subblock := range blocks {
		candidates := SeekXor(subblock)
		xorBlocks[i] = candidates
	}
	for i := 0; i < 3; i++ {
		batch := make(XorCandidates, 0)
		for j := 0; i < size; j++ {
			log.Printf("Got %d/%d\n", j, i)
			batch = append(batch, xorBlocks[j][i])
		}
		xorCandidates = append(xorCandidates,
			mergeXorCandidates(batch))
	}
	sort.Sort(ByScore{xorCandidates})
	return xorCandidates
}