Last active
April 2, 2025 13:29
-
-
Save TinoDidriksen/6f6606a90dd4e6d94b8c34f8b80b2fcd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use utf8; | |
| use Digest::SHA qw(sha256_base64); | |
| sub hash_base62 { | |
| my ($s, $n) = @_; | |
| utf8::encode($s); | |
| $s = sha256_base64($s); | |
| $s =~ s@=+@@g; | |
| $s =~ s@[+]@x@g; | |
| $s =~ s@/@X@g; | |
| return substr($s, 0, $n); | |
| } | |
| my $i = 0; | |
| while (my $line = <STDIN>) { | |
| ++$i; | |
| my $h = hash_base62($line . $i, 14); | |
| print "$h\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment