From 7731832751ab9f3c6ddeb66f186d3d7fa1934a6d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 13:11:40 +0200 Subject: Adding upstream version 2.4.57+dfsg. Signed-off-by: Daniel Baumann --- contrib/slapd-modules/passwd/apr1-ltoa.pl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 contrib/slapd-modules/passwd/apr1-ltoa.pl (limited to 'contrib/slapd-modules/passwd/apr1-ltoa.pl') diff --git a/contrib/slapd-modules/passwd/apr1-ltoa.pl b/contrib/slapd-modules/passwd/apr1-ltoa.pl new file mode 100644 index 0000000..ee628ec --- /dev/null +++ b/contrib/slapd-modules/passwd/apr1-ltoa.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl -w + +# OpenLDAP {APR1} to Apache $apr1$ hash converter +# (C) 2011 Devin J. Pohly +# You may use this code freely. It would be nice to be credited. + +use MIME::Base64; + +while (<>) { + ($user, $hash) = split(/:/, $_); + unless ($hash =~ /^{APR1}/) { + print STDERR "Not an Apache MD5 hash\n"; + next; + } + + chomp $hash; + $hash = decode_base64(substr($hash, 6)); + ($hash, $salt) = (substr($hash, 0, 16), substr($hash, 16)); + $hash = $hash; + $hash =~ s/(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)/$1$7$13$2$8$14$3$9$15$4$10$16$5$11$6\0\0$12/s; + $hash = encode_base64($hash); + chomp $hash; + $hash =~ s/(.)(.)(.)(.)/$4$3$2$1/gs; + unless ($hash =~ /AA$/) { + #print "Problem with hash\n"; + next; + } + $hash =~ s/AA$//; + $hash =~ tr|A-Za-z0-9+/|./0-9A-Za-z|; + print "$user:\$apr1\$$salt\$$hash\n" +} \ No newline at end of file -- cgit v1.2.3