mirror of
https://git.unlock-music.dev/um/cli.git
synced 2025-07-08 07:22:12 +08:00
refactor: use io.Reader instead of custom method
This commit is contained in:
21
algo/xm/xm_cipher.go
Normal file
21
algo/xm/xm_cipher.go
Normal file
@ -0,0 +1,21 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user