@@ -4,11 +4,11 @@ use sha1::Sha1;
44use super :: rc4:: RC4 ;
55
66const ENCRYPTION_KEY : [ u8 ; 16 ] = [
7- 0xCC , 0x98 , 0xAE , 0x04 , 0xE8 , 0x97 , 0xEA , 0xCA , 0x12 , 0xDD , 0xC0 , 0x93 , 0x42 , 0x91 , 0x53 , 0x57
7+ 0xCC , 0x98 , 0xAE , 0x04 , 0xE8 , 0x97 , 0xEA , 0xCA , 0x12 , 0xDD , 0xC0 , 0x93 , 0x42 , 0x91 , 0x53 , 0x57 ,
88] ;
99
1010const DECRYPTION_KEY : [ u8 ; 16 ] = [
11- 0xC2 , 0xB3 , 0x72 , 0x3C , 0xC6 , 0xAE , 0xD9 , 0xB5 , 0x34 , 0x3C , 0x53 , 0xEE , 0x2F , 0x43 , 0x67 , 0xCE
11+ 0xC2 , 0xB3 , 0x72 , 0x3C , 0xC6 , 0xAE , 0xD9 , 0xB5 , 0x34 , 0x3C , 0x53 , 0xEE , 0x2F , 0x43 , 0x67 , 0xCE ,
1212] ;
1313
1414#[ derive( Debug ) ]
@@ -18,18 +18,17 @@ pub struct HeaderEncryptor {
1818
1919impl HeaderEncryptor {
2020 pub fn new ( secret : & [ u8 ] ) -> Self {
21- let mut encryptor = RC4 :: new (
22- HmacSha :: new ( & ENCRYPTION_KEY , secret, Sha1 :: default ( ) ) . compute_digest ( ) . to_vec ( )
23- ) ;
21+ let mut encryptor =
22+ RC4 :: new ( & HmacSha :: new ( & ENCRYPTION_KEY , secret, Sha1 :: default ( ) ) . compute_digest ( ) ) ;
2423
25- let _ = & encryptor. encrypt ( & vec ! [ 0 ; 1024 ] ) ;
24+ encryptor. encrypt ( & mut vec ! [ 0 ; 1024 ] ) ;
2625
2726 Self {
2827 _instance : encryptor,
2928 }
3029 }
3130
32- pub fn encrypt ( & mut self , data : & [ u8 ] ) -> Vec < u8 > {
31+ pub fn encrypt ( & mut self , data : & mut [ u8 ] ) {
3332 self . _instance . encrypt ( data)
3433 }
3534}
@@ -41,18 +40,17 @@ pub struct HeaderDecryptor {
4140
4241impl HeaderDecryptor {
4342 pub fn new ( secret : & [ u8 ] ) -> Self {
44- let mut decryptor = RC4 :: new (
45- HmacSha :: new ( & DECRYPTION_KEY , secret, Sha1 :: default ( ) ) . compute_digest ( ) . to_vec ( )
46- ) ;
43+ let mut decryptor =
44+ RC4 :: new ( & HmacSha :: new ( & DECRYPTION_KEY , secret, Sha1 :: default ( ) ) . compute_digest ( ) ) ;
4745
48- let _ = & decryptor. encrypt ( & vec ! [ 0 ; 1024 ] ) ;
46+ decryptor. encrypt ( & mut vec ! [ 0 ; 1024 ] ) ;
4947
5048 Self {
5149 _instance : decryptor,
5250 }
5351 }
5452
55- pub fn decrypt ( & mut self , data : & [ u8 ] ) -> Vec < u8 > {
53+ pub fn decrypt ( & mut self , data : & mut [ u8 ] ) {
5654 self . _instance . encrypt ( data)
5755 }
58- }
56+ }
0 commit comments