====== WAEncrypt method for PHP ====== -function WAEncrypt($src, $key){ $pkey = $key; while (strlen($pkey)<16) $pkey .= '0'; $chars = 'abdefhiknrstyzABDEFGHKNQRSTYZ23456789'; $numChars = strlen($chars); $iv = ''; for ($i = 0; $i < 16; $i++) { $iv .= substr($chars, rand(1, $numChars) - 1, 1); } $block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, 'cbc'); $pad = $block - (strlen($src) % $block); $src .= str_repeat(chr($pad), $pad); $enc = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $pkey, $src, MCRYPT_MODE_CBC, $iv); return $iv.'|'.base64_encode($enc); }