use 5.012; use warnings; use Math::GMPz qw(:mpz ); use Digest::SHA qw(sha512_hex); my $sha = sha512_hex('password'); my $op = Rmpz_init_set_str($sha, 16); my $rop = Rmpz_init2(512); Rmpz_nextprime($rop, $op); say Rmpz_get_str($rop, 16);