52 lines
1.3 KiB
PHP
Executable File
52 lines
1.3 KiB
PHP
Executable File
#!/usr/bin/php
|
|
<?php
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
|
|
use nur\A;
|
|
use nur\cli\Application;
|
|
use nur\passwd\EtuPasswordGenerator;
|
|
|
|
Application::run(new class extends Application {
|
|
const ARGS = [
|
|
["-2", "name" => "version", "value" => 2],
|
|
["-3", "name" => "version", "value" => 3],
|
|
["-4", "name" => "version", "value" => 4],
|
|
];
|
|
|
|
protected $version;
|
|
|
|
protected $args;
|
|
|
|
function main() {
|
|
$version = $this->version;
|
|
if ($version === null) $version = 4;
|
|
$pg = new class($version) extends EtuPasswordGenerator {
|
|
function gen3seed(int $codEtu): int {
|
|
return parent::gen3seed($codEtu);
|
|
}
|
|
function gen4seed(int $codEtu): int {
|
|
return parent::gen4seed($codEtu);
|
|
}
|
|
};
|
|
$year = intval(date("y"));
|
|
$prefix = intval(A::get($this->args, 0, $year + 20)) % 100;
|
|
|
|
$codetu = $prefix * 1000000 + 1;
|
|
$max = ($prefix + 1) * 1000000;
|
|
$prev = 0;
|
|
echo "codetu,seed,delta,password\n";
|
|
while ($codetu < $max) {
|
|
switch ($version) {
|
|
case 3: $seed = $pg->gen3seed($codetu); break;
|
|
case 4: $seed = $pg->gen4seed($codetu); break;
|
|
default: $seed = null; break;
|
|
}
|
|
$delta = $seed - $prev;
|
|
$password = $pg->generate($codetu);
|
|
echo "$codetu,$seed,$delta,\"$password\"\n";
|
|
$prev = $seed;
|
|
$codetu++;
|
|
}
|
|
}
|
|
});
|