Code Duplication    Length = 14-15 lines in 2 locations

api/functions.php 1 location

@@ 2165-2179 (lines=15) @@
2162
    }
2163
}
2164
2165
function teampass_pbkdf2_hash($p, $s, $c, $kl, $st = 0, $a = 'sha256')
2166
{
2167
    $kb = $st + $kl;
2168
    $dk = '';
2169
2170
    for ($block = 1; $block <= $kb; $block++) {
2171
        $ib = $h = hash_hmac($a, $s.pack('N', $block), $p, true);
2172
        for ($i = 1; $i < $c; $i++) {
2173
            $ib ^= ($h = hash_hmac($a, $h, $p, true));
2174
        }
2175
        $dk .= $ib;
2176
    }
2177
2178
    return substr($dk, $st, $kl);
2179
}
2180

sources/main.functions.php 1 location

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