You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
373 B
Go
22 lines
373 B
Go
2 years ago
|
package xm
|
||
|
|
||
|
type xmCipher struct {
|
||
|
mask byte
|
||
|
encryptStartAt int
|
||
|
}
|
||
|
|
||
|
func newXmCipher(mask byte, encryptStartAt int) *xmCipher {
|
||
|
return &xmCipher{
|
||
|
mask: mask,
|
||
|
encryptStartAt: encryptStartAt,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (c *xmCipher) Decrypt(buf []byte, offset int) {
|
||
|
for i := 0; i < len(buf); i++ {
|
||
|
if offset+i >= c.encryptStartAt {
|
||
|
buf[i] ^= c.mask
|
||
|
}
|
||
|
}
|
||
|
}
|