Skip to content

Instantly share code, notes, and snippets.

@advincze
Created Nov 21, 2016
Embed
What would you like to do?
func pearson(msg, iv []byte, bytecount int) []byte {
var h byte
hh := make([]byte, bytecount)
for j := 0; j < bytecount; j++ {
h = iv[(int(msg[0])+j)%256]
for i := 1; i < len(msg); i++ {
h = iv[h^msg[i]]
}
hh[j] = h
}
return hh
}
func scramble(seed []byte) []byte {
ss := make([]byte, 256)
for i := 0; i < 256; i++ {
ss[i] = byte(i)
}
j := 0
for i := 0; i < 256; i++ {
j = (j + int(ss[i]) + int(seed[i%len(seed)])) % 256
ss[i], ss[j] = ss[j], ss[i]
}
return ss
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment