@@ -5,7 +5,7 @@ let crypto = require('crypto');
5
5
try {
6
6
var savedKeys = require ( "./config.js" ) . k ;
7
7
} catch ( e ) {
8
- Promise . reject ( 'No Configuration Exists!' ) ;
8
+ return Promise . reject ( 'No Configuration Exists!' ) ;
9
9
}
10
10
11
11
var ALGORITHM , KEY , HMAC_ALGORITHM , HMAC_KEY ;
@@ -39,7 +39,7 @@ var constant_time_compare = function (val1, val2) {
39
39
module . exports = {
40
40
41
41
"encrypt" : function ( plain_text ) {
42
- if ( ! plain_text || typeof ( plain_text ) !== "string" ) Promise . reject ( "Plain text not found." ) ;
42
+ if ( ! plain_text || typeof ( plain_text ) !== "string" ) return Promise . reject ( "Plain text not found." ) ;
43
43
44
44
var IV = Buffer . from ( randomValueHex ( 16 ) ) ; // ensure that the IV (initialization vector) is random
45
45
var encryptor , cipher_text , hmac ;
@@ -60,7 +60,7 @@ module.exports = {
60
60
} ,
61
61
62
62
"decrypt" : function ( cipher_text ) {
63
- if ( ! cipher_text || typeof ( cipher_text ) !== "string" || ! cipher_text . match ( "$" ) ) Promise . reject ( "A valid cipher text not found." ) ;
63
+ if ( ! cipher_text || typeof ( cipher_text ) !== "string" || ! cipher_text . match ( "$" ) ) return Promise . reject ( "A valid cipher text not found." ) ;
64
64
65
65
var cipher_blob = cipher_text . split ( "$" ) ;
66
66
var ct = cipher_blob [ 0 ] ;
@@ -73,7 +73,7 @@ module.exports = {
73
73
chmac . update ( IV . toString ( 'hex' ) ) ;
74
74
75
75
if ( ! constant_time_compare ( chmac . digest ( 'hex' ) , hmac ) ) {
76
- Promise . reject ( "Encrypted Blob has been tampered with." ) ;
76
+ return Promise . reject ( "Encrypted Blob has been tampered with." ) ;
77
77
}
78
78
79
79
decryptor = crypto . createDecipheriv ( ALGORITHM , KEY , IV ) ;
0 commit comments