All of the web service queries require DES encryption and MD5 hashing before sending to ensure the content has no modification during transmission.
Please ask us for the following information:
- Secret Key
- EncrypKey
- MD5Key
- API URL
- Lobby name (supplied during startup the client)
Example DES Encrypt function in ASP.Net C#:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
protected byte[] EncryptKey = ASCIIEncoding.ASCII.GetBytes("ask_us_for_key"); public string DESEncrypt( string inString) { MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream (ms, new DESCryptoServiceProvider ().CreateEncryptor(EncryptKey, EncryptKey), CryptoStreamMode .Write); StreamWriter sw = new StreamWriter (cs); sw.Write(inString); sw.Flush(); cs.FlushFinalBlock(); sw.Flush(); return Convert.ToBase64String(ms.GetBuffer(), 0, ( int )ms.Length); } |
Example DES Encrypt function in PHP:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<!--?php class DES { var $key; var $iv; function DES( $key, $iv=0 ) { $this--->key = $key; if( $iv == 0 ) { $this->iv = $key; } else { $this->iv = $iv; } } function encrypt($str) { return base64_encode( openssl_encrypt($str, 'DES-CBC', $this->key, OPENSSL_RAW_DATA, $this->iv ) ); } } ?> |
Example in PHP:
1 2 3 4 5 6 7 8 |
<!--?php $str = "method=GetUserStatus&Key=01234567789ABCDEF0123456789ABCDE&Time=20150101012345&Username=abcd12345"; // for example $key = 'ZyXw4321'; // for example $crypt = new DES($key); $mstr = $crypt--->encrypt($str); $urlemstr = urlencode($mstr); echo "[ $str ] Encrypted: [ $mstr ] UrlEncoded encrypted string: [ $urlemstr ]"; ?> |
Example MD5 function in ASP.Net C#:
1 2 3 4 5 6 7 8 9 10 |
public string BuildMD5(string inString) { byte[] hashed = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(inString)); StringBuilder sb = new StringBuilder(hashed.Length * 2); for (int i = 0; i < hashed.Length; i++) { sb.Append(hashed[i].ToString("x2")); } return sb.ToString(); } |
Example MD5 function in PHP:
1 2 3 4 5 6 7 8 9 |
<!--?php $str = "method=GetUserStatus&Key=01234567789ABCDEF0123456789ABCDE&Time=20150101012345&Username=abcd12345"; // for example $md5key = "abcdefg"; // for example $Time = "20150101012345"; // for example $SecretKey = "01234567789ABCDEF0123456789ABCDE"; // for example $PreMD5Str = $str . $md5key . $Time . $SecretKey; $OutMD5 = md5($PreMD5Str); echo "md5:[ $OutMD5 ]"; ?--> |