@@ -63,6 +63,12 @@ export default class P2PEncryptor {
63
63
const enc = new TextEncoder ( ) ;
64
64
const arr = enc . encode ( str ) ;
65
65
66
+ // const base64 = btoa(str);
67
+ // const inputWA = CryptoJS.enc.Base64.parse(base64);
68
+ // const input8Arr = wordArrayToUint8Array(inputWA);
69
+
70
+ // const packet = this.encryptRawPacket(input8Arr);
71
+ // console.log('[arr] ', arr, input8Arr);
66
72
const packet = this . encryptRawPacket ( new Uint8Array ( arr ) ) ;
67
73
68
74
const { bytes } = packet ;
@@ -194,7 +200,7 @@ export default class P2PEncryptor {
194
200
const encrypted = CryptoJS . AES . encrypt ( str , key , {
195
201
mode : CryptoJS . mode . CTR ,
196
202
iv,
197
- padding : CryptoJS . pad . ZeroPadding
203
+ padding : CryptoJS . pad . NoPadding
198
204
} ) ;
199
205
200
206
const result = wordArrayToUint8Array ( encrypted . ciphertext ) ;
@@ -206,7 +212,7 @@ export default class P2PEncryptor {
206
212
const decrypted = CryptoJS . AES . decrypt ( { ciphertext : str } , key , {
207
213
mode : CryptoJS . mode . CTR ,
208
214
iv,
209
- padding : CryptoJS . pad . ZeroPadding
215
+ padding : CryptoJS . pad . NoPadding
210
216
} ) ;
211
217
212
218
const result = wordArrayToUint8Array ( decrypted ) ;
@@ -265,6 +271,7 @@ export default class P2PEncryptor {
265
271
return null ;
266
272
}
267
273
274
+ console . log ( '[base64] decryptionBuffer' , decryptionBuffer ) ;
268
275
const resultBuffer = decryptionBuffer . slice ( 4 ) ;
269
276
270
277
return resultBuffer ;
0 commit comments