lib/pbkdf2_sha512-sjcl.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 18
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
wmc 3
nc 1
mnd 0
bc 3
fnc 3
dl 0
loc 18
rs 10
bpm 1
cpm 1
noi 1
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A pbkdf2_sha512-sjcl.js ➔ pbkdf2Sha512 0 5 1
A pbkdf2_sha512-sjcl.js ➔ hmacSha512 0 6 1
1
var sjcl = require('sjcl');
2
3
var hmacSha512 = function(key) {
4
    var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
5
    this.encrypt = function() {
6
        return hasher.encrypt.apply(hasher, arguments);
7
    };
8
};
9
10
var pbkdf2Sha512 = function(pw, salt, iterations, keySizeBytes) {
11
    salt = sjcl.codec.hex.toBits(salt.toString('hex'));
12
    var data = sjcl.codec.hex.toBits(pw.toString('hex'));
13
    return new Buffer(sjcl.codec.hex.fromBits(sjcl.misc.pbkdf2(data, salt, iterations, keySizeBytes * 8, hmacSha512)), 'hex');
0 ignored issues
show
Bug introduced by
The variable Buffer seems to be never declared. If this is a global, consider adding a /** global: Buffer */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
14
};
15
16
module.exports = {
17
    digest: pbkdf2Sha512
18
};
19