跳到主要内容

命令行调用

该命令行为了方便测试运行的正确性,添加了加密的选项。你可以使用命令行进行加密文件的生成。

使用 v2 解密/加密
cargo run kugou --slot-key-1 "base64:MDlBWg==" \
sample/test_kgm_header_v2.kgm decrypted.ogg

cargo run kugou --slot-key-1 "base64:MDlBWg==" \
--encrypt-header "@sample/kgm_header_v2.bin" \
sample/test_121529_32kbps.ogg enc_v2.kgm
使用 v3 解密/加密
cargo run kugou --slot-key-1 "base64:MDlBWg==" \
sample/test_kgm_header_v3.kgm decrypted.ogg

cargo run kugou --slot-key-1 "base64:MDlBWg==" \
--encrypt-header "@sample/kgm_header_v3.bin" \
sample/test_121529_32kbps.ogg enc_v3.kgm
使用 v4 解密/加密
cargo run kugou --slot-key-1 "base64:MDlBWg==" \
--v4-file-key-expansion-table "@sample/test_kgm_v4_filekey_table.bin" \
--v4-slot-key-expansion-table "@sample/test_kgm_v4_slotkey_table.bin" \
sample/test_kgm_header_v4.kgm decrypted.ogg

cargo run kugou --slot-key-1 "base64:MDlBWg==" \
--encrypt-header "@sample/kgm_header_v4.bin" \
--v4-file-key-expansion-table "@sample/test_kgm_v4_filekey_table.bin" \
--v4-slot-key-expansion-table "@sample/test_kgm_v4_slotkey_table.bin" \
sample/test_121529_32kbps.ogg enc_v4.kgm

参数

  • --slot-key-1 - 插槽序号对应的密钥。
  • --encrypt-header - 切换为加密模式,并使用指定的模板进行加密。
  • --v4-file-key-expansion-table - 用于文件密钥处理的展开表(v4 限定)。
  • --v4-slot-key-expansion-table - 用于插槽密钥处理的展开表(v4 限定)。

之后附加两个参数,分别为 输入文件路径输出文件路径

测试密钥

1 号插槽:

--slot-key-1 "base64:MDlBWg=="
 
04
00
A
  
 
00
01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00
 
30
39
41
5a
  
  
  
  
  
  
  
  
  
  
  
  
 
0 
9 
A 
Z 
 
 
 
 
 
 
 
 
 
 
 
 

2 号加密使用的文件头示例:

--encrypt-header "@sample/kgm_header_v2.bin"
 
40
00
A
  
 
00
01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00
 
7c
d5
32
eb
86
02
7f
4b
a8
af
a6
8e
0f
ff
99
14
 
| 
. 
2 
. 
. 
. 
 
K 
. 
. 
. 
. 
. 
. 
. 
. 
10
 
00
04
00
00
02
00
00
00
01
00
00
00
5b
46
69
6c
 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
[ 
F 
i 
l 
20
 
65
4b
65
79
53
69
67
6e
61
74
75
5d
5b
44
65
63
 
e 
K 
e 
y 
S 
i 
g 
n 
a 
t 
u 
] 
[ 
D 
e 
c 
30
 
72
79
70
74
69
6f
6e
20
4b
65
79
5d
00
00
00
00
 
r 
y 
p 
t 
i 
o 
n 
 
K 
e 
y 
] 
. 
. 
. 
. 

3 号加密使用的文件头示例:

--encrypt-header "@sample/kgm_header_v3.bin"
 
40
00
A
  
 
00
01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00
 
7c
d5
32
eb
86
02
7f
4b
a8
af
a6
8e
0f
ff
99
14
 
| 
. 
2 
. 
. 
. 
 
K 
. 
. 
. 
. 
. 
. 
. 
. 
10
 
00
04
00
00
03
00
00
00
01
00
00
00
5b
46
69
6c
 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
[ 
F 
i 
l 
20
 
65
4b
65
79
53
69
67
6e
61
74
75
5d
5b
44
65
63
 
e 
K 
e 
y 
S 
i 
g 
n 
a 
t 
u 
] 
[ 
D 
e 
c 
30
 
72
79
70
74
69
6f
6e
20
4b
65
79
5d
00
00
00
00
 
r 
y 
p 
t 
i 
o 
n 
 
K 
e 
y 
] 
. 
. 
. 
. 

4 号加密使用的文件密钥展开表:

--v4-file-key-expansion-table "@sample/test_kgm_v4_filekey_table.bin"
 
02c1
00
A
    
 
00
01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0000
 
4c
6f
72
65
6d
20
69
70
73
75
6d
20
64
6f
6c
6f
 
L 
o 
r 
e 
m 
 
i 
p 
s 
u 
m 
 
d 
o 
l 
o 
0010
 
72
20
73
69
74
20
61
6d
65
74
2c
20
63
6f
6e
73
 
r 
 
s 
i 
t 
 
a 
m 
e 
t 
, 
 
c 
o 
n 
s 
0020
 
65
63
74
65
74
75
72
20
61
64
69
70
69
73
63
69
 
e 
c 
t 
e 
t 
u 
r 
 
a 
d 
i 
p 
i 
s 
c 
i 
0030
 
6e
67
20
65
6c
69
74
2e
20
4e
75
6c
6c
61
6d
20
 
n 
g 
 
e 
l 
i 
t 
. 
 
N 
u 
l 
l 
a 
m 
 
0040
 
6d
61
78
69
6d
75
73
20
69
61
63
75
6c
69
73
20
 
m 
a 
x 
i 
m 
u 
s 
 
i 
a 
c 
u 
l 
i 
s 
 
0050
 
6e
75
6c
6c
61
20
73
65
64
20
66
72
69
6e
67
69
 
n 
u 
l 
l 
a 
 
s 
e 
d 
 
f 
r 
i 
n 
g 
i 
0060
 
6c
6c
61
2e
20
53
65
64
20
6e
65
71
75
65
20
6c
 
l 
l 
a 
. 
 
S 
e 
d 
 
n 
e 
q 
u 
e 
 
l 
0070
 
65
6f
2c
20
73
6f
64
61
6c
65
73
20
61
74
20
6c
 
e 
o 
, 
 
s 
o 
d 
a 
l 
e 
s 
 
a 
t 
 
l 
0080
 
69
67
75
6c
61
20
69
64
2c
20
70
72
65
74
69
75
 
i 
g 
u 
l 
a 
 
i 
d 
, 
 
p 
r 
e 
t 
i 
u 
0090
 
6d
20
62
69
62
65
6e
64
75
6d
20
61
75
67
75
65
 
m 
 
b 
i 
b 
e 
n 
d 
u 
m 
 
a 
u 
g 
u 
e 
00a0
 
2e
20
41
6c
69
71
75
61
6d
20
76
65
68
69
63
75
 
. 
 
A 
l 
i 
q 
u 
a 
m 
 
v 
e 
h 
i 
c 
u 
00b0
 
6c
61
20
65
72
6f
73
20
6e
6f
6e
20
6e
75
6e
63
 
l 
a 
 
e 
r 
o 
s 
 
n 
o 
n 
 
n 
u 
n 
c 
00c0
 
20
6d
61
74
74
69
73
20
66
61
75
63
69
62
75
73
 
 
m 
a 
t 
t 
i 
s 
 
f 
a 
u 
c 
i 
b 
u 
s 
00d0
 
2e
20
53
65
64
20
65
67
65
74
20
6d
69
20
76
69
 
. 
 
S 
e 
d 
 
e 
g 
e 
t 
 
m 
i 
 
v 
i 
00e0
 
74
61
65
20
65
78
20
67
72
61
76
69
64
61
20
72
 
t 
a 
e 
 
e 
x 
 
g 
r 
a 
v 
i 
d 
a 
 
r 
00f0
 
75
74
72
75
6d
2e
20
44
75
69
73
20
76
69
74
61
 
u 
t 
r 
u 
m 
. 
 
D 
u 
i 
s 
 
v 
i 
t 
a 
0100
 
65
20
66
65
6c
69
73
20
65
74
20
74
75
72
70
69
 
e 
 
f 
e 
l 
i 
s 
 
e 
t 
 
t 
u 
r 
p 
i 
0110
 
73
20
69
6e
74
65
72
64
75
6d
20
62
6c
61
6e
64
 
s 
 
i 
n 
t 
e 
r 
d 
u 
m 
 
b 
l 
a 
n 
d 
0120
 
69
74
2e
20
4e
75
6c
6c
61
6d
20
76
69
74
61
65
 
i 
t 
. 
 
N 
u 
l 
l 
a 
m 
 
v 
i 
t 
a 
e 
0130
 
20
65
73
74
20
69
6e
74
65
72
64
75
6d
2c
20
6f
 
 
e 
s 
t 
 
i 
n 
t 
e 
r 
d 
u 
m 
, 
 
o 
0140
 
72
6e
61
72
65
20
64
69
61
6d
20
73
69
74
20
61
 
r 
n 
a 
r 
e 
 
d 
i 
a 
m 
 
s 
i 
t 
 
a 
0150
 
6d
65
74
2c
20
64
69
67
6e
69
73
73
69
6d
20
61
 
m 
e 
t 
, 
 
d 
i 
g 
n 
i 
s 
s 
i 
m 
 
a 
0160
 
72
63
75
2e
20
44
6f
6e
65
63
20
6d
6f
6c
65
73
 
r 
c 
u 
. 
 
D 
o 
n 
e 
c 
 
m 
o 
l 
e 
s 
0170
 
74
69
65
20
76
65
6e
65
6e
61
74
69
73
20
73
63
 
t 
i 
e 
 
v 
e 
n 
e 
n 
a 
t 
i 
s 
 
s 
c 
0180
 
65
6c
65
72
69
73
71
75
65
2e
20
44
75
69
73
20
 
e 
l 
e 
r 
i 
s 
q 
u 
e 
. 
 
D 
u 
i 
s 
 
0190
 
66
69
6e
69
62
75
73
20
6d
61
6c
65
73
75
61
64
 
f 
i 
n 
i 
b 
u 
s 
 
m 
a 
l 
e 
s 
u 
a 
d 
01a0
 
61
20
64
6f
6c
6f
72
20
73
65
64
20
69
61
63
75
 
a 
 
d 
o 
l 
o 
r 
 
s 
e 
d 
 
i 
a 
c 
u 
01b0
 
6c
69
73
2e
20
51
75
69
73
71
75
65
20
6d
61
78
 
l 
i 
s 
. 
 
Q 
u 
i 
s 
q 
u 
e 
 
m 
a 
x 

4 号加密使用的文件密码槽展开表:

--v4-slot-key-expansion-table "@sample/test_kgm_v4_slotkey_table.bin"
 
02c8
00
A
    
 
00
01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0000
 
4c
6f
72
65
6d
20
69
70
73
75
6d
20
64
6f
6c
6f
 
L 
o 
r 
e 
m 
 
i 
p 
s 
u 
m 
 
d 
o 
l 
o 
0010
 
72
20
73
69
74
20
61
6d
65
74
2c
20
63
6f
6e
73
 
r 
 
s 
i 
t 
 
a 
m 
e 
t 
, 
 
c 
o 
n 
s 
0020
 
65
63
74
65
74
75
72
20
61
64
69
70
69
73
63
69
 
e 
c 
t 
e 
t 
u 
r 
 
a 
d 
i 
p 
i 
s 
c 
i 
0030
 
6e
67
20
65
6c
69
74
2e
20
53
65
64
20
71
75
69
 
n 
g 
 
e 
l 
i 
t 
. 
 
S 
e 
d 
 
q 
u 
i 
0040
 
73
20
6f
72
6e
61
72
65
20
6e
69
62
68
2e
20
44
 
s 
 
o 
r 
n 
a 
r 
e 
 
n 
i 
b 
h 
. 
 
D 
0050
 
6f
6e
65
63
20
76
69
76
65
72
72
61
20
68
65
6e
 
o 
n 
e 
c 
 
v 
i 
v 
e 
r 
r 
a 
 
h 
e 
n 
0060
 
64
72
65
72
69
74
20
61
6c
69
71
75
61
6d
2e
20
 
d 
r 
e 
r 
i 
t 
 
a 
l 
i 
q 
u 
a 
m 
. 
 
0070
 
4d
6f
72
62
69
20
65
67
65
73
74
61
73
20
70
75
 
M 
o 
r 
b 
i 
 
e 
g 
e 
s 
t 
a 
s 
 
p 
u 
0080
 
6c
76
69
6e
61
72
20
6e
65
71
75
65
20
65
74
20
 
l 
v 
i 
n 
a 
r 
 
n 
e 
q 
u 
e 
 
e 
t 
 
0090
 
70
65
6c
6c
65
6e
74
65
73
71
75
65
2e
20
53
75
 
p 
e 
l 
l 
e 
n 
t 
e 
s 
q 
u 
e 
. 
 
S 
u 
00a0
 
73
70
65
6e
64
69
73
73
65
20
66
65
72
6d
65
6e
 
s 
p 
e 
n 
d 
i 
s 
s 
e 
 
f 
e 
r 
m 
e 
n 
00b0
 
74
75
6d
20
62
69
62
65
6e
64
75
6d
20
72
69
73
 
t 
u 
m 
 
b 
i 
b 
e 
n 
d 
u 
m 
 
r 
i 
s 
00c0
 
75
73
20
71
75
69
73
20
66
72
69
6e
67
69
6c
6c
 
u 
s 
 
q 
u 
i 
s 
 
f 
r 
i 
n 
g 
i 
l 
l 
00d0
 
61
2e
20
44
75
69
73
20
65
75
20
76
69
76
65
72
 
a 
. 
 
D 
u 
i 
s 
 
e 
u 
 
v 
i 
v 
e 
r 
00e0
 
72
61
20
6d
61
73
73
61
2e
20
45
74
69
61
6d
20
 
r 
a 
 
m 
a 
s 
s 
a 
. 
 
E 
t 
i 
a 
m 
 
00f0
 
6e
6f
6e
20
6e
69
73
69
20
73
65
64
20
72
69
73
 
n 
o 
n 
 
n 
i 
s 
i 
 
s 
e 
d 
 
r 
i 
s 
0100
 
75
73
20
64
69
67
6e
69
73
73
69
6d
20
74
69
6e
 
u 
s 
 
d 
i 
g 
n 
i 
s 
s 
i 
m 
 
t 
i 
n 
0110
 
63
69
64
75
6e
74
2e
20
50
72
61
65
73
65
6e
74
 
c 
i 
d 
u 
n 
t 
. 
 
P 
r 
a 
e 
s 
e 
n 
t 
0120
 
20
72
75
74
72
75
6d
20
69
6e
74
65
72
64
75
6d
 
 
r 
u 
t 
r 
u 
m 
 
i 
n 
t 
e 
r 
d 
u 
m 
0130
 
20
74
72
69
73
74
69
71
75
65
2e
20
41
6c
69
71
 
 
t 
r 
i 
s 
t 
i 
q 
u 
e 
. 
 
A 
l 
i 
q 
0140
 
75
61
6d
20
63
6f
6e
64
69
6d
65
6e
74
75
6d
20
 
u 
a 
m 
 
c 
o 
n 
d 
i 
m 
e 
n 
t 
u 
m 
 
0150
 
64
69
61
6d
20
76
65
6c
20
74
72
69
73
74
69
71
 
d 
i 
a 
m 
 
v 
e 
l 
 
t 
r 
i 
s 
t 
i 
q 
0160
 
75
65
20
66
65
72
6d
65
6e
74
75
6d
2e
20
4e
75
 
u 
e 
 
f 
e 
r 
m 
e 
n 
t 
u 
m 
. 
 
N 
u 
0170
 
6e
63
20
75
6c
74
72
69
63
65
73
20
6c
6f
62
6f
 
n 
c 
 
u 
l 
t 
r 
i 
c 
e 
s 
 
l 
o 
b 
o 
0180
 
72
74
69
73
20
6e
75
6e
63
20
63
6f
6e
76
61
6c
 
r 
t 
i 
s 
 
n 
u 
n 
c 
 
c 
o 
n 
v 
a 
l 
0190
 
6c
69
73
20
63
6f
6d
6d
6f
64
6f
2e
20
51
75
69
 
l 
i 
s 
 
c 
o 
m 
m 
o 
d 
o 
. 
 
Q 
u 
i 
01a0
 
73
71
75
65
20
65
67
65
73
74
61
73
20
6d
65
74
 
s 
q 
u 
e 
 
e 
g 
e 
s 
t 
a 
s 
 
m 
e 
t 
01b0
 
75
73
20
76
69
74
61
65
20
65
78
20
64
69
63
74
 
u 
s 
 
v 
i 
t 
a 
e 
 
e 
x 
 
d 
i 
c 
t