Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Three menggunakan enkripsi tripledes - ECB
- // Fungsi cryptECB diambil dari sini http://www.isapp.it/en/menu-en/31-tips-a-tricks/php/118-php-how-to-encrypt-text-in-triple-des-ecb.html
- function cryptECB($crypt, $key) {
- $iv_size = mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_ECB);
- $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- // crypting
- $cryptText = mcrypt_encrypt(MCRYPT_3DES, $key, $crypt, MCRYPT_MODE_ECB, $iv);
- return $cryptText;
- }
- // inisialisasi data
- $key = "c5ec069257f724be";
- $msisdn = "";
- $password = "";
- if (empty($msisdn) && empty($password)) {
- echo 'MSISDN dan PASSWORD harus diisi!';
- exit(0);
- }
- // ada string replacement juga pada saat enkripsi data
- $search_replace = array(
- '+' => '-',
- '/' => '_',
- );
- // replace msisdn dan password yang sudah dienkripsi lalu hasilnya diencode juga ke base 64
- $crypt_msisdn = str_replace(
- array_keys($search_replace),
- array_values($search_replace),
- base64_encode(cryptECB($msisdn, $key))
- );
- $crypt_password = str_replace(
- array_keys($search_replace),
- array_values($search_replace),
- base64_encode(cryptECB($password, $key))
- );
- // url sign in
- $url = 'http://180.214.232.99/pro/sso/signin';
- // json data untuk dipost
- $build_post = array(
- 'model' => 'sdk',
- 't_width' => '220',
- 't_height' => '220',
- 'msisdn' => $crypt_msisdn,
- 'user_agent' => 'Mozilla',
- 'brand' => 'generic',
- 'secret_key' => '52fb2db0ea6625ff',
- 'password' => $crypt_password,
- 'version' => '1.6.0'
- );
- $json_data = json_encode($build_post);
- $fields = array(
- 'jsondata' => urlencode($json_data),
- );
- $fields_string = '';
- foreach($fields as $key=>$value) {
- $fields_string .= $key.'='.$value.'&';
- }
- rtrim($fields_string, '&');
- // buka koneksi
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL, $url);
- curl_setopt($ch,CURLOPT_POST, count($fields));
- curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
- $result = curl_exec($ch);
- curl_close($ch);
- ?>
Add Comment
Please, Sign In to add comment