2022-11-19 18:18:50 +00:00
|
|
|
package xiami
|
2022-11-18 23:25:43 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|