Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
function gen_password($seed, $username, $password_resets, $m = 2147483648, $count = 10) {
$results = [];
$x = $seed;
$a = crc32($username) % $m;
for ($i = 0; $i < $count; $i++) {
$x = ($a * $x + $password_resets) % $m;
$results[] = $x;
}
return $results;
}
print(gen_password(0, "test", 0))
<?php
function gen_password($seed, $username, $password_resets) {
$result = 0;
$x = $seed;
$a = crc32($username) % PHP_INT_MAX;
for ($i = 0; $i <= $password_resets; $i++) {
$x = ($a * $x) % PHP_INT_MAX;
$result = $x;
}
print($result);
print(' ');
$password = '';
do {
$charCode = ($result % 94) + 33;
$result = intdiv($result, 94);
$password .= chr($charCode);
} while ($result !== 0);
return $password;
}
$pw = gen_password(3, "admin", 0);
print(strlen($pw));
print(' ');
print($pw);