From d896925dff6ecc78037e9bb008ae6306db8a24e5 Mon Sep 17 00:00:00 2001 From: Unlock Music Dev Date: Sun, 20 Nov 2022 03:12:30 +0800 Subject: [PATCH] fix(kwm): allow new magic header --- algo/kwm/kwm.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/algo/kwm/kwm.go b/algo/kwm/kwm.go index 5e533c8..166e732 100644 --- a/algo/kwm/kwm.go +++ b/algo/kwm/kwm.go @@ -12,7 +12,8 @@ import ( "unlock-music.dev/cli/algo/common" ) -const magicHeader = "yeelion-kuwo-tme" +const magicHeader1 = "yeelion-kuwo-tme" +const magicHeader2 = "yeelion-kuwo\x00\x00\x00\x00" const keyPreDefined = "MoOtOiTvINGwd2E6n0E1i7L5t2IoOoNk" type Decoder struct { @@ -43,7 +44,9 @@ func (d *Decoder) Validate() error { } // check magic header, 0x00 - 0x0F - if !bytes.Equal([]byte(magicHeader), header[:len(magicHeader)]) { + magicHeader := header[:0x10] + if !bytes.Equal([]byte(magicHeader1), magicHeader) && + !bytes.Equal([]byte(magicHeader2), magicHeader) { return errors.New("kwm magic header not matched") }