sql - MySQL MD5 hash to base64 -


i have mysql db stores users info (username, pass, etc). building ldap server back-sql , works fine except password field. passwords basic md5 hashes so

select md5('testpass01')

returns

428a65ed9de7dbf8ef7d08f884528440

apparently hexpair representation of binary value. ldap understand base64 encoded string this

{md5}qopl7z3n2/jvfqj4hfkeqa==

i found perl script conversion

#!/usr/bin/perl use mime::base64; use strict; @md5 = split "",$argv[0]; @res; (my $i = 0 ; $i < 32 ; $i+=2) { $c = (((hex $md5[$i]) << 4) % 255) | (hex $md5[$i+1]); $res[$i/2] = chr $c; print $c; } print "{md5}".encode_base64(join "", @res); #-------------------------------------------# 

my question is: possible conversion using sql through stored procedure? cannot install mysql server 5.6 includes base64 encode , decode functions

thanks

it works perfectly. using function in comments produce base64 password ldap accept.

select base64_encode(unhex('mysql-md5-encoded-password')


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -