Skip to content

Instantly share code, notes, and snippets.

@advincze
Created November 21, 2016 16:32
Show Gist options
  • Save advincze/e53024183ff9588788b7832a51e1f684 to your computer and use it in GitHub Desktop.
Save advincze/e53024183ff9588788b7832a51e1f684 to your computer and use it in GitHub Desktop.
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