Function compute URL ($ input ){ $ Base32 = array ( 'A', 'B', 'C', 'D', 'E', 'E', 'F', 'G', 'h ', 'I', 'J', 'k', 'l', 'M', 'n', 'O', 'P ', 'Q', 'R', 's', 't', 'U', 'V', 'w', 'x ', 'Y', 'z', '0', '1', '2', '3', '4', '5' ); $ Hex = md5 ($ input );
$ HexLen = strlen ($ hex ); $ SubHexLen = $ hexLen/8; $ Output = array (); For ($ I = 0; $ I <$ subHexLen; $ I ++ ){
$ SubHex = substr ($ hex, $ I * 8, 8 ); $ Int = 0x3FFFFFFF & (1 * ('0x '. $ subHex )); $ Out = ''; For ($ j = 0; $ j <6; $ j ++ ){
$ Val = 0x0000001F & $ int; $ Out. = $ base32 [$ val]; $ Int = $ int> 5; } $ Output [] = $ out;
} Return $ output;
} Sample code to test/use the above function:
$ Input = 'HTTP: // www. bKjia. c0m/1 '; $ Output = Response URL ($ input ); Echo "Input: $ inputn ";
Echo "Output: {$ output [0]} n "; Echo "{$ output [1]} n "; Echo "{$ output [2]} n "; Echo "{$ output [3]} n "; Echo "n "; $ Input = 'HTTP: // www. bKjia. c0m/2 ';
$ Output = Response URL ($ input ); Echo "Input: $ inputn ";
Echo "Output: {$ output [0]} n "; Echo "{$ output [1]} n "; Echo "{$ output [2]} n "; Echo "{$ output [3]} n "; Echo "n "; Output:
Http://www.bKjia. c0m/1 Output: h0xg4r Bdr3tw Osk2d3 4 azfqa Http://www.bKjia. c0m/2
Output: tm5kxb Ceoj2s Yw3dvl Nrmrxl |