clear
p = "password"
salt = "ftsafe"
iter = 08
x = call script_pbkdf2_sha256( $p, $salt, $iter, 20 )
y = pbkdf2_sha256( $p, $salt, $iter, 20 )
if $x != $y
?
pause
endif
x = call script_pbkdf2_sha256( $p, $salt, $iter, 70 )
y = pbkdf2_sha256( $p, $salt, $iter, 70 )
if $x != $y
?
pause
endif
end
script_pbkdf2_sha256:
prompt off
local password
local salt
local iterations
local needlen
local count
local t
local u
local dk
password = getpara
salt = getpara
iterations = getpara
needlen = getpara
count = 01
dk = ""
max = hex( ( 0x$needlen + 31 ) / 32 )
hfor i = 01 to $max
count = leftpack( $count, 4 )
count = right( $count, 4 )
u = hmac_sha256( $salt $count, $password )
t = $u
hfor j = 01 to hex( 0x$iterations - 1 )
u = hmac_sha256( $u, $password )
t = memxor( $t, 00, $u )
hnext j
dk = $dk $t
count = add( $count, 01 )
hnext i
dk = hmid( $dk, 00, $needlen )
prompt on
return $dk