-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusergen
38 lines (27 loc) · 878 Bytes
/
usergen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl
use bytes;
use Digest::SHA;
use MIME::Base64;
use Math::BigInt;
($path_to_file, $pass, $salt) = @ARGV;
unless (defined($salt)) {
print "Insufficient parameters", "\n", "Use: usergen <path_to_userlist_file> <pass> <salt>", "\n";
exit 1;
}
my $handle;
unless (open $handle, "<:encoding(utf8)", $path_to_file) {
print STDERR "Could not open file '$path_to_file': $!\n";
exit 2;
}
chomp(my @names = <$handle>);
unless (close $handle) {
# what does it mean if close yields an error and you are just reading?
print STDERR "Error while closing '$path_to_file': $!\n";
}
$names_size = scalar @names;
$hash = Digest::SHA::sha1_hex($salt, $pass);
$hash_num = Math::BigInt->from_hex($hash);
$index = $hash_num->bmod($names_size);
$index = $index->numify();
$number = $hash_num->bmod(989)->numify() + 11;
print $names[$index], $number, "\n";