refactor: use io.Reader instead of custom method

This commit is contained in:
Unlock Music Dev
2022-11-19 07:25:43 +08:00
parent 4365628bff
commit 67ff0c44cd
17 changed files with 420 additions and 460 deletions

21
algo/xm/xm_cipher.go Normal file
View 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
}
}
}