Phpjavades
API said in the login time account needs des encryption, the password needs des and MD5 encryption, but I used several DES encryption is the authentication failed.
I'm using Java, here is the PHP code I found from the Thinksns, ask the good people to turn into Java, PHP really do not understand
class DES_MOBILE {
var $key = '12345678';
function Setkey ($key) {$this->key = $key; return $this;} function Encrypt ($string) {$ivArray =array (0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF); $iv =null; foreach ($ivArray as $element) $iv. =CHR ($element); $size = Mcrypt_get_block_size (Mcrypt_des, MCRYPT_MODE_CBC); $string = $this->pkcs5pad ($string, $size); $data = Mcrypt_encrypt (mcrypt_des, $this->key, $string, MCRYPT_MODE_CBC, $IV); $data = Base64_encode ($data); return $data;} function Decrypt ($string) {$ivArray =array (0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF); $iv =null; foreach ($ivArray as $element) $iv. =CHR ($element); $string = Base64_decode ($string); $result = Mcrypt_decrypt (mcrypt_des, $this->key, $string, MCRYPT_MODE_CBC, $IV); $result = $this->pkcs5unpad ($result); return $result;} function Pkcs5pad ($text, $blocksize) {$pad = $blocksize-(strlen ($text)% $blocksize); Return $text. Str_repeat (Chr ($pad), $PAD); } function Pkcs5unpad ($text) {$pad = Ord ($text {strlen ($text)-1}); if ($pad > strlen ($text)) return false; if (strspn ($text, Chr ($pad), strlen ($text)-$pad)! = $pad) return false; Return substr ($text, 0,-1 * $pad); }
}