mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-08-02 11:36:08 -04:00
addressing issues found by codacy
This commit is contained in:
parent
0f76b9066d
commit
717e5b0e57
5 changed files with 8 additions and 10 deletions
|
@ -736,7 +736,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
{name: 'PBKDF2'}, // we use PBKDF2 for key derivation
|
||||
false, // the key may not be exported
|
||||
['deriveKey'] // we may only use it for key derivation
|
||||
)
|
||||
);
|
||||
|
||||
// derive a stronger key for use with AES
|
||||
const derivedKey = await window.crypto.subtle.deriveKey(
|
||||
|
@ -754,7 +754,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
},
|
||||
false, // the key may not be exported
|
||||
['encrypt'] // we may only use it for decryption
|
||||
)
|
||||
);
|
||||
|
||||
// finally, encrypt message
|
||||
const encrypted = await window.crypto.subtle.encrypt(
|
||||
|
@ -767,7 +767,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
},
|
||||
derivedKey,
|
||||
StrToArr(compress(message)) // compressed plain text to encrypt
|
||||
)
|
||||
);
|
||||
object.ct = btoa(ArrToStr(encrypted));
|
||||
return JSON.stringify(object);
|
||||
};
|
||||
|
@ -821,7 +821,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
},
|
||||
false, // the key may not be exported
|
||||
['decrypt'] // we may only use it for decryption
|
||||
)
|
||||
);
|
||||
|
||||
// finally, decrypt message
|
||||
const decrypted = await window.crypto.subtle.decrypt(
|
||||
|
@ -834,7 +834,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||
},
|
||||
derivedKey,
|
||||
StrToArr(atob(object.ct)) // cipher text to decrypt
|
||||
)
|
||||
);
|
||||
return decompress(ArrToStr(decrypted));
|
||||
} catch(err) {
|
||||
return '';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue