input = "Hello World";
// The number of iterations change the hash
dump( hash( input=input, numIterations=1 ) ); // B10A8DB164E0754105B7A99BE72E3FE5
dump( hash( input=input, numIterations=9 ) ); // 5E1C304FD939BBE1378ED977E2AD26B5
// numIterations less than 1 are set to 1
dump( hash( input=input, numIterations=0 ) == hash( input=input, numIterations=1 ) ); // true
// More iterations take more time
// 1000 SHA-512s, 1 iteration each: 5ms
bx:timer type="inline" label="1000 SHA-512s, 1 iteration each" {
for( i = 0; i < 1000; i++ ) {
hash( input=input, algorithm="SHA-512", numIterations=1 );
}
}
writeOutput( "<br>" );
// 1000 SHA-512s, 10 iterations each: 21ms
bx:timer type="inline" label="1000 SHA-512s, 10 iterations each" {
for( i = 0; i < 1000; i++ ) {
hash( input=input, algorithm="SHA-512", numIterations=10 );
}
}