Code Duplication    Length = 14-15 lines in 2 locations

api/functions.php 1 location

@@ 2155-2169 (lines=15) @@
2152
    }
2153
}
2154
2155
function teampass_pbkdf2_hash($p, $s, $c, $kl, $st = 0, $a = 'sha256')
2156
{
2157
    $kb = $st + $kl;
2158
    $dk = '';
2159
2160
    for ($block = 1; $block <= $kb; $block++) {
2161
        $ib = $h = hash_hmac($a, $s.pack('N', $block), $p, true);
2162
        for ($i = 1; $i < $c; $i++) {
2163
            $ib ^= ($h = hash_hmac($a, $h, $p, true));
2164
        }
2165
        $dk .= $ib;
2166
    }
2167
2168
    return substr($dk, $st, $kl);
2169
}
2170

sources/main.functions.php 1 location

@@ 49-62 (lines=14) @@
46
}
47
48
//generate pbkdf2 compliant hash
49
function strHashPbkdf2($p, $s, $c, $kl, $a = 'sha256', $st = 0)
50
{
51
    $kb = $st + $kl; // Key blocks to compute
52
    $dk = ''; // Derived key
53
54
    for ($block = 1; $block <= $kb; $block++) { // Create key
55
        $ib = $h = hash_hmac($a, $s.pack('N', $block), $p, true); // Initial hash for this block
56
        for ($i = 1; $i < $c; $i++) { // Perform block iterations
57
            $ib ^= ($h = hash_hmac($a, $h, $p, true)); // XOR each iterate
58
        }
59
        $dk .= $ib; // Append iterated block
60
    }
61
    return substr($dk, $st, $kl); // Return derived key of correct length
62
}
63
64
/**
65
 * stringUtf8Decode()