Enkripsi: Rfc2898DeriveBytes di C# dan hash_pbkdf2 di php

C#

    public string DecryptText(string input, string password)
    {
        String[] tempAry = input.Split('-');

        byte[] bytesToBeDecrypted = new byte[tempAry.Length];
        for (int i = 0; i < tempAry.Length; i++)
            bytesToBeDecrypted[i] = Convert.ToByte(tempAry[i], 16);

        byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
        passwordBytes = SHA256.Create().ComputeHash(passwordBytes);

        byte[] bytesDecrypted = Decrypt(bytesToBeDecrypted, passwordBytes);

        return Encoding.UTF8.GetString(bytesDecrypted);

    }
    public byte[] Decrypt(byte[] bytesToBeDecrypted, byte[] passwordBytes)
    {
        byte[] decryptedBytes = null;
        byte[] saltBytes = new byte[] { 5, 7, 3, 5, 2, 6, 7, 8 };
        using (MemoryStream ms = new MemoryStream())
        {
            using (RijndaelManaged AES = new RijndaelManaged())
            {
                AES.KeySize = 256;
                AES.BlockSize = 128;
                var key = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000);
                AES.Key = key.GetBytes(AES.KeySize / 8);
                AES.IV = key.GetBytes(AES.BlockSize / 8);
                AES.Mode = CipherMode.CBC;
                using (var cs = new CryptoStream(ms, AES.CreateDecryptor(), 
                                                 CryptoStreamMode.Write))
                {
                    cs.Write(bytesToBeDecrypted, 0, bytesToBeDecrypted.Length);
                    cs.Close();
                }
                decryptedBytes = ms.ToArray();
            }
        }
        return decryptedBytes;
    }

PHP

function DecryptText ($input, $password){
    $tempAry = str_replace("-", "", $input);

    $bytesToBeDecryptedbin = hex2bin($tempAry); 
    $bytesToBeDecrypted = unpack('C*', $bytesToBeDecryptedbin);
    $bytesToBeDecryptedbinstring = "";
    for($i=0;$i<count($bytesToBeDecrypted);$i++){
        $bytesToBeDecryptedbinstring=$bytesToBeDecryptedbinstring.chr($bytesToBeDecrypted[$i+1]);
    }


    $passwordhash = hash('sha256', $password); 
    $passwordbin = hex2bin($passwordhash); 
    $passwordBytes = unpack('C*', $passwordbin);
    $passwordBytesstring = "";
    for($i=0;$i<count($passwordBytes);$i++){
        $passwordBytesstring=$passwordBytesstring.chr($passwordBytes[$i+1]);
    }

    $saltBytes = array(5,7,3,5,2,6,7,8);
    $saltBytesstring = "";
    for($i=0;$i<count($saltBytes);$i++){
        $saltBytesstring=$saltBytesstring.chr($saltBytes[$i]);
    }
    
    $keySize = 256; $blockSize = 128;

    $key = hash_pbkdf2("sha1", $passwordBytesstring, $saltBytesstring, 1000, 48, true); 
    $aeskey = (  substr($key,0,$keySize/8) );
    $aesiv =  (  substr($key,$keySize/8,$blockSize/8) );

    $decrypted = mcrypt_decrypt
          (
              MCRYPT_RIJNDAEL_128,
              $aeskey,
              $bytesToBeDecryptedbinstring,
              MCRYPT_MODE_CBC,
              $aesiv
           );        

    $result = "";
    for($i=0;$i<strlen($decrypted);$i++){
        if($decrypted[$i]==chr(7)) break;
        $result = $result . $decrypted[$i];
    }
           
    $decryptedarr = unpack('C*', $result);
    return $result;
}

sumber:

http://stackoverflow.com/questions/43011612/porting-c-sharp-rfc2898derivebytes-in-php-using-hash-pbkdf2

 

Menghilangkan pop-up di semarpen

Saat browsing menggunakan mifi semarpen, rasanya agak kesal karena setiap membuka alamat web disuguhi iklan pop up. Jadi harus baca dulu baru halaman web yang tertuju dibuka.

Setelah install pop-up blocker dan no script (add on firefox), pop up ilkan tidk muncul lagi. Eh, ternyata yang muncul adalah halaman kosong. Misalnya buka https://latiful.hayat.web.id maka munculnya:

image-1

Jika dilihat page source (Ctrl + U) ternyata ada injeksi script

<script>
function go(w,u){xc=1;w.frames[0].location=u;}
var flag_lte=1;
var xu='http://192.168.185.20:8080/CustomerInfo/',lxu=xu+'Customer';
var xc=-1,d=document,w=window,ip='100.119.142.98',vid='348',md='628818533749',u=location.href,hs=location.hostname,lci='&lac=%l%&ci=%c%';
gd = d.createElement("script");gd.src=xu+"m.js";d.documentElement.firstChild.appendChild(gd);
var scr2=d.createElement("script");scr2.src=xu+"y.js";d.documentElement.firstChild.appendChild(scr2);
var scr=d.createElement("script");scr.src=xu+"x.js";d.documentElement.firstChild.appendChild(scr);
var s='http://192.168.185.20:8080/CustomerInfo/Customer?mdn='+md+'&user-agent=Samsung&url='+encodeURIComponent("https://latiful.hayat.web.id/")+'&lac=3101&ci=80686111';
var mp='<meta id="xvw" name="viewport" content="width=device-width,user-scalable=';
var httpRequest;
if (hs.indexOf("www.")==0)mp=mp+'yes">';else mp=mp+'no,initial-scale=1">';d.writeln(mp);
// var o=d.createElement("script");o.src=xu+"b.js";d.documentElement.firstChild.appendChild(o);
d.writeln('<meta charset="utf-8" />');
</script>
<body style="margin:0;height:100%;">
</body>

Browsing kesana kemari akhirnya menemukan Link dari situs favorit saat menemukan masalah (stackoverflow.com) ternyata ada solusi untuk menghilangkan iframe injeksi dari semarpen dengan mengganti konfigurasi lewat perintah about:config yang dituliskan di address bar. Ganti:

network.http.accept.default: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

menjadi

network.http.accept.default: */*

Jika menggunakan google chrome:

Install header hacker dan buka setting. Isikan

title:NO IFRAME
Append/replace: replace with
String: */*
Match string: .*  lalu klik add.

Lalu buka pilihan permanent header (di bagian kiri), isikan

Domain: .* 
Header swicth: NO IFRAME

oleh Latiful Hayat

Sumber: http://www.nicois.me/2015/05/ada-apa-dengan-smartfren-dan-iframe.html

Belajar Bahasa Arab 03: laa, lam, maa, lan, laisa

LAM dan LAA ( لم لا )

hanya dipakai untuk Kata Kerja Sekarang, sedangkan ( ما ) maa biasanya dipakai untuk Kata Kerja Lampau

Secara kaidah grammar, LAA titerapkan yang huruf terakhirnya di dhommah. Misal:

Saya tidak faham : انا لا أفهم- ana laa afhamu

sedangkan sesudah LAM, huruf terakhir di sukun. Sehingga penulisannya:

Saya tidak faham: انا لم أفهم - ana lam afham

(menurut sebagian orang, LAM itu Tidak nya bersifat MUTLAK)

 

MAA

dipakai untuk Kata Kerja Lampau.

Saya sudah paham : فهمتُ - fahimtu
Saya tidak sudah paham : ما فهمتُ - maa fahimtu

Catatan bahasa Indonesia “Saya tidak sudah paham” agak membingungkan mungkin, padanan bahasa Inggrisnya: I have not understood.

 

LAN

adalah meniadakan peristiwa/pekerjaan akan datang

Tidak akan berhenti: لَنْ نَبْرَح - LAN NABROHA

LAISA (M) atau LAISAT (F)

digunakan untuk kalimat non verbal (bukan kata kerja):

Ceritanya tidak menarik: ليست القصة ممتعة - laisat al-kessatu momte'a

LAISA untuk kata keterangan orang ditambahi TA/NA, bisa menjadi LASTU (saya tidak), LASTA (kamu tidak – M), LASTI (kamu tidak – F), LASNA (kami tidak)

 

Sumber:

  • http://arabquran.blogspot.co.id/2007/10/topik-47-latihan-surat-al-ikhlas-ayat-3.html
  • http://www.everyday-arabic.com/2013/12/negation-in-arabic-language.html
  • https://nahwusharaf.wordpress.com/2012/04/13/fiil-mudhari-manshub-sebab-amil-nawashib-lan-kay-an-%D9%84%D9%86-%D9%83%D9%8A-%D8%A3%D9%86-alfiyah-bait-677-678/

Belajar Bahasa Arab 02: na’am, balaa, dan labbaika

Apa persamaan dan perbedaan dari kata na’am, balaa, dan labbaika?

نعم, بلى, لبّيك

Persamaan: ketiga kata ini umumnya digunakan oleh seseorang untuk menyahut/menjawab orang yang memanggilnya.

Perbedaan: ketiga kata ini berbeda dalam aspek tata krama bahasa. Penjelasannya diberikan dalam ilustrasi berikut.

Sahabat Nabi rodhiyallohu ‘anhu:

  • Bila dipanggil oleh sesama kawan, beliau menjawab dengan na’am
  • Bila dipanggil oleh Nabi, beliau menjawab dengan balaa
  • Bila ‘dipanggil’ oleh Alloh (misal, perintah untuk haji), beliau menjawab dengan labbaika

Dari ilustrasi ini, kita ketahui bahwa:

  • Na’am: untuk kawan sebaya
  • Balaa: untuk orang yang lebih tua, pemimpin, ulama, dan semisalnya
  • Labbaika: untuk Alloh khususnya

sumber: http://www.mnurq.ga/2014/01/naam-balaa-dan-labbaika.html

Contoh bridging BPJS dengan PHP (Contoh Formulir request dan response)

Berikut contoh bridging BPJS dengan PHP, mencakup:

Referensi
Kode atau Nama Diagnosa
Pencarian data poli
Fasilitas Kesehatan

Kepesertaan
Berdasar NIK
Berdasar No. Kartu

SEP
Detail SEP Peserta
Monitoring Verifikasi Klaim
Data Kunjungan Peserta
Data Riwayat Pelayanan Peserta
Integrasi SEP dengan Inacbg 4.1

Pada contoh ini terdiri dari 2 file, yaitu getform.php sebagai contoh formulir dan getresponse.php sebagai skrip untuk request ke server BPJS

File form (contoh formulir): getform.php

<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

<script>
  $( function() {
      
    $( "#tglMasuk" ).datepicker({
        dateFormat: "yy-mm-dd"
    });
    $( "#tglKeluar" ).datepicker({
        dateFormat: "yy-mm-dd"
    });
    
  });
</script>
  
<script>

$(document).ready(function(){

    
    $("#DIAG").click(function(){
        var parameter = $('#paramDIAG').val();
        if (parameter==""){alert ("Diagnosa harus diisi"); return;}
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/diagnosa/ref/diagnosa/&arr=1", 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });

     $("#POLI").click(function(){
        var parameter = '';
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/poli/ref/poli&arr=1", 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });

    $("#FASKES").click(function(){
        var parameter = $('#paramFASKES').val();
        var mulai = $('#mulaiFASKES').val();
        var limit = $('#limitFASKES').val();
        var uri = "&start="+mulai+"&limit="+limit;
        var url="getresponse.php?parameter="+parameter+encodeURIComponent(uri)+"&arr=1&cat=/provider/ref/provider/query%3Fnama=";  //tanda ? --> url encode mjd %3F
        if (parameter==""){alert ("FASKES harus diisi"); return;}
        $("#div1").load(url, 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });


    $("#NIK").click(function(){
        var parameter = $('#paramNIK').val();
        if (parameter==""){alert ("NIK harus diisi"); return;}
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/Peserta/Peserta/nik/&arr=1", 
        function(responseTxt, statusTxt, xhr){
       if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });
    
    $("#NO").click(function(){
        var parameter = $('#paramNO').val();
        if (parameter==""){alert ("No. Kartu harus diisi"); return;}
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/Peserta/Peserta/&arr=1", 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });    
    
     $("#DETSEP").click(function(){
        var parameter = $('#paramDETSEP').val();
        if (parameter==""){alert ("SEP harus diisi"); return;}
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/SEP/&arr=1", 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });
    
    
    
     $("#VERSEP").click(function(){
        var parameter = "tglMasuk/" + $('#tglMasuk').val() + "/tglKeluar/" + $('#tglKeluar').val() + "/KlsRawat/" + $('#kelas').val() + "/Kasus/" + $('#kasus').val() + "/Cari/" + $('#cari').val() + "/status/" + $('#status').val();    
        if (parameter==""){alert ("SEP harus diisi"); return;}
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/sep/integrated/Kunjungan/&arr=1", 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });
    
    
   $("#SEPKUN").click(function(){
        var parameter = $('#paramSEPKUN').val();
        if (parameter==""){alert ("SEP harus diisi"); return;}
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/sep/integrated/Kunjungan/sep/&arr=1", 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });
    
   $("#NOR").click(function(){
        var parameter = $('#paramNOR').val();
        if (parameter==""){alert ("No Kartu harus diisi"); return;}
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/sep/peserta/&arr=1", 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
    });
    
   $("#CBG").click(function(){
        var parameter = $('#paramCBG').val();
        if (parameter==""){alert ("SEP harus diisi"); return;}
        $("#div1").load("getresponse.php?parameter="+parameter+"&cat=/sep/cbg/&arr=1", 
        function(responseTxt, statusTxt, xhr){
        if(statusTxt == "error")
            alert("Error: " + xhr.status + ": " + xhr.statusText);
        });
        
    });
    
    $("button").click(function(){
        $("html, body").animate({ scrollTop: 0 }, "slow");
    });

    
});
</script>
</head>
<body>
<div id="div1"><h2>Hasil akan tampil disini</h2></div>
<hr />

<h2> Referensi</h2>
<h3> Diagnosa</h3>
<p> Kode atau Nama Diagnosa: <input type="text" id="paramDIAG"  value=""/>
<button id="DIAG">Kirim</button></p>

<h3> Poli</h3>
<p> Pencarian data poli: 
<button id="POLI">Kirim</button></p>

<h3> Fasilitas Kesehatan</h3>
<p> Nama atau kode faskes: <input type="text" id="paramFASKES"  value=""/>
<button id="FASKES">Kirim</button><br />
 Mulai: <input type="text" id="mulaiFASKES"  value="0"/><br />
 Limit: <input type="text" id="limitFASKES"  value="7"/>
</p>

<hr />

<h2> Kepesertaan </h2>
<h3> Berdasar NIK </h3>
<p> NIK: <input type="text" id="paramNIK"  value=""/>
<button id="NIK">Kirim</button></p>

<h3> Berdasar No. Kartu </h3>
<p> No.Kartu BPJS: <input type="text" id="paramNO"  value=""/>
<button id="NO">Kirim</button></p>

<hr />
<h2> SEP </h2>

<h3> Detail SEP Peserta </h3>
<p> No.SEP: <input type="text" id="paramDETSEP"  value=""/>
<button id="DETSEP">Kirim</button></p>

<h3> Monitoring Verifikasi Klaim </h3>
<p> 
Tanggal Masuk: <input type="text" id="tglMasuk"  value=""/><br />
Tanggal Keluar: <input type="text" id="tglKeluar"  value=""/><br />
Kelas rawat: <select id="kelas" required>
   <option selected="selected" value="">Pilih</option>
  <option value="1">Kelas 1</option>
  <option value="2">Kelas 2</option>
  <option value="3">Kelas 3</option>
</select><br />
JnsPelayanan : <select id="kasus" required>
   <option selected="selected" value="">Pilih</option>
  <option value="1">Rawat inap</option>
  <option value="2">Rawat jalan</option>
</select><br />
Cari berdasar : <select id="cari" required>
   <option selected="selected" value="">Pilih</option>
  <option value="0">Tanggal masuk</option>
  <option value="1">Tanggal keluar</option>
</select><br />
Status  : <select id="status" required>
   <option selected="selected" value="">Pilih</option>
  <option value="00">Klaim Baru</option>
  <option value="10">Klaim Terima CBG</option>
  <option value="21">Klaim Layak</option>
  <option value="22">Klaim Tidak Layak</option>
  <option value="23">Klaim Pending</option>
  <option value="30">Terverifikasi</option>
  <option value="40">Proses Cabang</option>
</select><br />
<button id="VERSEP">Kirim</button><br />
</p>

<h3> Data Kunjungan Peserta </h3>
<p> Nomor SEP: <input type="text" id="paramSEPKUN"  value=""/>
<button id="SEPKUN">Kirim</button></p>

<h3> Data Riwayat Pelayanan Peserta </h3>
<p> No.Kartu BPJS: <input type="text" id="paramNOR"  value=""/>
<button id="NOR">Kirim</button></p>

<h3> Integrasi SEP dengan Inacbg 4.1 </h3>
<p> Nomor SEP: <input type="text" id="paramCBG"  value=""/>
<button id="CBG">Kirim</button></p>

</body>
</html>

File response: getresponse.php

<?php

if(!isset($_GET["parameter"])) exit(0);
if(!isset($_GET["cat"])) exit(0);
$printarr=false;
if(isset($_GET["arr"])) $printarr=true;
$extraparam="";
if(isset($_GET["extraparam"])) $extraparam=$_GET["extraparam"];

$parameter = $_GET["parameter"];
$cat = $_GET["cat"];

$dataid    = "1234"; //Ganti dengan consumerID dari BPJS
$secretKey = "5678"; //Ganti dengan consumerSecret dari BPJS
$localIP   = "dvlp.bpjs-kesehatan.go.id";
$port      = 8081; //port url
$url       = "http://".$localIP.":".$port."/devwslokalrest".$cat.$parameter; //Lihat katalog, jangan sertakan port

date_default_timezone_set('UTC');
$tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
$signature = hash_hmac('sha256', $dataid."&".$tStamp, $secretKey, true);
$encodedSignature = base64_encode($signature);
$urlencodedSignature = urlencode($encodedSignature);

/*
echo "X-cons-id: " .$dataid ."<br>";
echo "X-timestamp:" .$tStamp ."<br>";
echo "X-signature: " .$encodedSignature."<br>";
*/

$opts = array(
 'http'=>array(
 'method'=>"GET",
 'header'=>"Host: api.asterix.co.id\r\n".
 "Connection: close\r\n".
 "X-timestamp: ".$tStamp."\r\n".
 "X-signature: ".$encodedSignature."\r\n".
 "User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64)\r\n".
 "X-cons-id: ".$dataid."\r\n".
 "Accept: application/json\r\n"
 )
);

$context = stream_context_create($opts);
$url=$url.$extraparam;
$result = file_get_contents($url, false, $context);

//echo "<br>Respon:";
if ($result === false) 
{ 
 echo "Tidak dapat menyambung ke server"; 
} else { 
 echo $result;
 if($printarr==true){
    echo "<pre>";
    print_r(json_decode($result, true)); 
    echo "</pre>";

    /*
    //contoh penggunaan array untuk menampilkan peserta
    $resultarr = json_decode($result, true);
    echo "Nama :". $resultarr['response']['peserta']['nama'] ."<br />";
    echo "Nik  :". $resultarr['response']['peserta']['nik'] ."<br />";
    echo "Lahir:". date("d-m-Y", strtotime($resultarr['response']['peserta']['tglLahir'])) ."<br />";
    echo "Usia :". $resultarr['response']['peserta']['umur']['umurSekarang'] ."<br />";
    echo "#Krtu:". $resultarr['response']['peserta']['noKartu'] ."<br />";
    echo "Sex  :". $resultarr['response']['peserta']['sex'] ."<br />";
    */
 }
}

?>

 

 

Contoh bridging BPJS dengan PHP (Update SEP)

<?php

$dataid = "1234"; //Ganti dengan consumerID dari BPJS
$secretKey = "5678"; //Ganti dengan consumerSecret dari BPJS
$localIP = "dvlp.bpjs-kesehatan.go.id";
$url = "http://".$localIP."/devwslokalrest/SEP/update"; //Lihat katalog, jangan sertakan port
$port = 8081; //port url

date_default_timezone_set('UTC');
date_default_timezone_set('Asia/Jakarta');

$tStamp = strval(time() - strtotime('1970-01-01 00:00:00'));
$signature = hash_hmac('sha256', $dataid . "&" . $tStamp, $secretKey, true);
$encodedSignature = base64_encode($signature);
$urlencodedSignature = urlencode($encodedSignature);

echo "X-cons-id: " . $dataid . "<br>";
echo "X-timestamp:" . $tStamp . "<br>";
echo "X-signature: " . $encodedSignature . "<br>";

function post_request($url, $port, $dataid, $tStamp, $encodedSignature, $data, $referer = '')
{
 
 //-Convert the data array into URL Parameters like a=b&foo=bar etc.
 //$data = http_build_query($data);
 
 // parse the given URL
 $url = parse_url($url);
 
 if ($url['scheme'] != 'http') {
 die('Error: Only HTTP request are supported !');
 }
 
 // extract host and path:
 $host = $url['host'];
 $path = $url['path'];
 
 // open a socket connection on port 80 - timeout: 50 sec
 $fp = fsockopen($host, $port, $errno, $errstr, 50);
 
 if ($fp) {
 
 // send the request headers:
 fputs($fp, "PUT $path HTTP/1.1\r\n");
 fputs($fp, "Host: $host\r\n");
 
 if ($referer != '')
 fputs($fp, "Referer: $referer\r\n");
 
 fputs($fp, "x-cons-id: " . $dataid . "\r\n");
 fputs($fp, "x-timestamp: " . $tStamp . "\r\n");
 fputs($fp, "x-signature: " . $encodedSignature . "\r\n");
 fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
 fputs($fp, "Content-length: " . strlen($data) . "\r\n");
 fputs($fp, "Connection: close\r\n\r\n");
 fputs($fp, $data);
 
 $result = '';
 while (!feof($fp)) {
 // receive the results of the request, 128 char
 $result .= fgets($fp, 128);
 }
 } else {
 return array(
 'status' => 'err',
 'error' => "$errstr ($errno)"
 );
 }
 
 // close the socket connection:
 fclose($fp);
 
 // split the result header from the content
 $result = explode("\r\n\r\n", $result, 2);
 
 $header = isset($result[0]) ? $result[0] : '';
 $content = isset($result[1]) ? $result[1] : '';
 
 // return as structured array:
 return array(
 'status' => 'ok',
 'header' => $header,
 'content' => $content
 );
 
}


$databpjs = '{
 "request":
 {
 "t_sep":
 {
 "noSep":"0301R00105160000579",
 "noKartu":"0000015223579",
 "tglSep":"2016-06-12 09:00:00",
 "tglRujukan":"2016-06-12 09:00:00",
 "noRujukan":"00009",
 "ppkRujukan":"00010009",
 "ppkPelayanan":"0301R009",
 "jnsPelayanan":"2",
 "catatan":"test",
 "diagAwal":"A00.1",
 "poliTujuan":"INT",
 "klsRawat":"3",
 "lakaLantas":"2",
 "lokasiLaka":"Banyumas",
 "user":"RS",
 "noMr":"001"
 }
 }
 }';

$data = array(
 'Data' => $databpjs
);


$result = post_request($url, $port, $dataid, $tStamp, $encodedSignature, $databpjs, $referer = '');
if ($result['status'] == 'ok') {
 // Print headers
 echo $result['header'];
 
 echo '<hr />';
 
 //mengubah "re d sponse" menjadi "response"
 $resultstr = str_replace("re d sponse", "response", trim(preg_replace('/\s\s+/', ' ', $result['content'])));

 //mengubah format ke JSON yang valid
 $pos = strpos($resultstr, "{");
 if ($pos === false) 
 $pos = 0;
 $rpos = strrpos($resultstr, "}");
 if ($rpos === false) 
 $rpos = strlen($resultstr);
 $resultstr = substr($resultstr,$pos,$rpos-$pos+1);
 
 // print the result of the whole request:
 echo "<pre>";
 echo $resultstr;
 echo "</pre>";
 
} else {
 echo 'A error occured: ' . $result['error'];
}

?>

Compile x86 (32 bit) pada Visual studio x64 (64 bit)

Secara bawaan, Visual Studio akan meng-compile platform sama dengan jenis sistem operasinya. Jika menggunakan platform x64, maka hasil compilasinya juga x64. Bagaimana cara compile program x86 (32 bit) pada Visual studio yang dijalankan di Windows x64 (64 bit)

Buka: Tools > Options

pilih “Show all settings”

Arahkan ke “Projects and Solutions > General” dan tandai (centang) “Show advanced build configurations”

setelah klik OK, maka muncul pilihan x64 dan x86 pada drop-down.

Source: http://captain-slow.dk/2010/07/12/build-in-x86-on-a-x64-platform-with-microsoft-visual-c-2010-express/

Cara membuka acakan siaran parabola jenis BISS

Langkah pertama: Mencari PID

Setelah siaran yang diacak direkam dalam bentuk TS (Transport Stream), lalu buka file melalui TSReader. Cari PID tayangan yang diacak. PID ditampilkan dalam format Hexadesimal. Untuk mengetahui dalam bentuk desimal, gunakan kalkulator dengan mode scientific. (Misal: 0x0031Hex = 49 Dec)

Langkah kedua: Brute dengan CW Finder

  • Buka file dan masukkan PID dalam bentuk desimal (Misal: 49)
  • Pilih menu Pilihan lanjut pilih Gunakan file daftar serangan
  • Buka file daftar kunci, klik Baca File, OK pada jendela Info, centang pada Gunakan daftar serangan, dilanjutkan dengan klik Gunakan pada jendela Daftar serangan CW
  • Semua jendela akan menutup otomatis
  • Klim menu Mulai, tunggu sebentar hingga muncul kode CW
Search Thread started...
CW found: 
A3 B2 C1 [16] D6 E5 F4 [AF]
Search Thread stoped...
  • Tinggal isikan kode (misal yang ditemukan di atas adalah: A3B2C116D6E5F4AF pada receiver

Jika langkah kedua gagal, gunakan langkah ketiga

  1. Cari kode Crypt8 dengan CSA Rainbow Table
  • Siapkan dahulu file rbt, CSA_B8hx00h_10000h.rbt (untuk jenis MP2) atau CSA_B8hxFFh_10000h.rbt (untuk jenis MP4)
  • Buka CSA Rainbow Table
  • Pada bagian TS file:, arahkan ke file TS
  • Pada bagian PID, isikan PIDnya (Misal: 49)
  • Klik tombol Start

csa

  • Pada contoh di atas, ditemukan 2 kode Crypt8, yaitu FD ED 27 37 23 ED 5E 5B dgn jumlah 231668 dan 08 E5 A3 EF F5 FB D5 78 dengan jumlah 34. Pilih yang jumlahnya paling banyak, yaitu: FD ED 27 37 23 ED 5E 5B
  • Copy yang telah dipilih lalu paste ke bagian Crypt8: FD ED 27 37 23 ED 5E 5B
  • Arahkan RBT Dir: ke tempat dimana file rbt atau CSA_B8hx00h_10000h.rbt berada
  • Klik tombol Start, maka hasil CW akan ditampilkan di bagian CW:
  • Tinggal isikan kode (misal yang ditemukan di atas adalah: A3B2C116D6E5F4AF pada receiver

 

Referensi: satelitindonesia.com

Contoh kode interupsi I2S pada WAU8822 pada Nuvoton NUC-LB140

Contoh loopback dari dan ke WAU serta pembentukan sinyal sinusoida

#include "NUC100Series.h"
#include "gpio.h"
#include "portinit.h" //lcd
#include "lcd.h"
#include "wau8822n.h"

# define PLLCON_SETTING      CLK_PLLCON_50MHz_HIRC
# define PLL_CLOCK           50000000
# define HCLK_DIV            1

#define MUTE_OFF(x)         PE->DOUT &= ~(1 << 14)
#define MUTE_ON(x)          PE->DOUT |=  (1 << 14)

//#define POOLING
#define LOOPBACK 1
#define MONOTOSTEREO 1
#define GAIN 1//50

#define SIN_SAMPLES     32
int32_t i32SinIdx = 0;
int16_t i16Sin[SIN_SAMPLES] = {
    0,3203,6284,9124,11612,13655,15172,16106,16423,16107,15172,13655,
    11613,9124,6284,3204,1,-3205,-6284,-9124,-11613,-13654,-15173,-16107,
    -16422,-16106,-15172,-13655,-11613,-9123,-6285,-3203
};

uint32_t g_u32TxValue;
uint32_t connect=TRUE;
void displayLCD(){

    //PC15=0;
    print_Line(0,   " Teknik Elektro ");
    printS(2*8+4,1*16,"Universitas"); //printS(x, y, char)
    printS(2*8,2*16,"Muhammadiyah");
    printS(3*8,3*16, "Purwokert0");
    connect=FALSE;

}

uint32_t spectrum[128];
volatile uint8_t ii=0;
extern void wau(void){
    uint8_t i;
    for(i=0;i<128;i++){
        spectrum[i]=0;
    }


    SYS_UnlockReg(); // Unlock protected registers
    CLK_EnableXtalRC(CLK_PWRCON_XTL12M_EN_Msk | CLK_PWRCON_OSC10K_EN_Msk ); // Enable HXT external 12MHz cyrstal
    CLK_SetCoreClock(50000000);    //  Set HCLK frequency 50MHz
    SYS_LockReg(); // Lock protected registers

    Port_Init(SPI3PORT);
    init_LCD();
    clear_LCD();

    //I2C - I2S WAU8822 codec
    WAU8822_Config();

    GPIO_SetMode(PE, BIT14, GPIO_PMD_OUTPUT);
    PE14=0;  //PHone OUT Enable (NUC-LB-140)

#ifdef POOLING
    //uint32_t u32Tmp;

    //open I2S function
    //st.u32SampleRate     = 16000;
    //st.u8WordWidth       = I2S_DATABIT_16;
    //st.u8AudioFormat     = I2S_STEREO;
    //st.u8DataFormat      = I2S_FORMAT_I2S;
    //st.u8Mode            = I2S_MODE_SLAVE;
    //st.u8TxFIFOThreshold = I2S_FIFO_TX_LEVEL_WORD_0;
    //st.u8RxFIFOThreshold = I2S_FIFO_RX_LEVEL_WORD_8;//SMP_ONE
    I2S_Open(I2S,I2S_MODE_MASTER,32000,I2S_DATABIT_16,I2S_STEREO,I2S_FORMAT_I2S);

    // Set MCLK and enable MCLK
    I2S_EnableMCLK(I2S,6000000);

    while(1)
    {

            if((I2S->STATUS & I2S_STATUS_TXFULL_Msk) == 0)
            {
                u32Tmp = i16Sini[i32SinIdxi];
                u32Tmp &= 0xFFFFUL;
                //u32Tmp |= u32Tmp << 16;  //duplicate it to stereo to Tx FIFO
                I2S->TXFIFO = u32Tmp;
                i32SinIdxi++;
                if(i32SinIdxi >= SIN_SAMPLESi)
                    i32SinIdxi = 0;

            }

    }
#else

    //interrupt
    I2S_Open(I2S,I2S_MODE_SLAVE,32000,I2S_DATABIT_16,I2S_STEREO,I2S_FORMAT_I2S);
    I2S_EnableMCLK(I2S,12000000);

    I2S_EnableInt(I2S,I2S_IE_RXTHIE_Msk );
    NVIC_EnableIRQ(I2S_IRQn);

    GPIO_SetMode(PC,BIT12,GPIO_PMD_OPEN_DRAIN);PA12=1;
    GPIO_SetMode(PC,BIT14,GPIO_PMD_OPEN_DRAIN);

    if(PE15==1) displayLCD();

    while(1)
    {
        CLK_SysTickDelay(1000000);
        if(PE15==0)
        {
            if(connect==FALSE) {
                clear_LCD();
                print_Line(0,   "Line-In Sound OK");
            }
            PC12 ^= 1;  //in LIN connected
            connect=TRUE;


        }else{
            if(connect){displayLCD();}

        }


    }
#endif
}

void I2S_IRQHandler(void)
{
    uint32_t u32Tmp=0;
    //unit32_t s =

    /* Fill sin samples to I2S until Tx FIFO full */
    while((I2S->STATUS & I2S_STATUS_TXFULL_Msk) == 0)
    {

#if LOOPBACK // Just loop Rx FIFO to Tx FIFO
        u32Tmp = I2S->RXFIFO;
        I2S->TXFIFO = (u32Tmp*GAIN);
#elif MONOTOSTEREO // Mono data in Rx FIFO and duplicate it to stereo to Tx FIFO
        u32Tmp = I2S->RXFIFO*GAIN & 0xFFFF0000UL;
        u32Tmp |= u32Tmp >> 16;
        I2S->TXFIFO = u32Tmp;

#else // Output Sin Wave
        u32Tmp = i16Sin[i32SinIdx];
        u32Tmp &= 0xFFFFUL;
        u32Tmp |= u32Tmp << 16;
        I2S->TXFIFO = u32Tmp;
        i32SinIdx++;
        if(i32SinIdx >= SIN_SAMPLES)
            i32SinIdx = 0;
#endif
    }
    ii = u32Tmp;
    PC->DOUT ^= (1 << 14);
}

Membuat HTPC dengan Linux Ubuntu

So, what is HTPC?

HTPC is Home Theater PC, from the name it can be guess that HTPC is a Home Theater using PC (Personal Computer). This is how to make it work:

Install XBMCBuntu

Setup LIRC

Keluar dari xbmc, login pilih ubuntu

klik Dash Home (logo ubuntu kiri atas) lalu ketik term, pilih UXterm

jika belum punya lirc, ketik:

sudo apt-get install lirc setserial

cari daftar remote yang support, di http://lirc.sourceforge.net/remotes/ misalnya dipilih remote TV Sharp http://lirc.sourceforge.net/remotes/sharp/G1324SA download dan copy ke share, ketik:

wget http://lirc.sourceforge.net/remotes/sharp/G1324SA

sudo mkdir /usr/share/lirc/remotes/sharp

sudo cp G1324SA /usr/share/lirc/remotes/sharp

perbaiki file hardware.conf dengan ketik:

sudo nano /etc/lirc/hardware.conf

perbaiki dengan:

# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="sharp" #isi dengan sharp atau nama remote apapun terserah
REMOTE_MODULES="lirc_dev lirc_serial" #tambahkan modul dev dan serial
REMOTE_DRIVER="default" #isi dengan default
REMOTE_DEVICE="/dev/lirc0" #defaultnya, cek dengan: ps ax | grep lirc
REMOTE_LIRCD_CONF="sharp/G1324SA" #isikan alamat conf remote yg tlh dicopy
REMOTE_LIRCD_ARGS=""

#tambahkan konfigurasi berikut
#ttyS0 berarti COM1 atau serial pertama, isikan ttyS1 jika COM2 dst
#lihat di ls /dev/ttyS*
#serial
COM_PORT=/dev/ttyS0  
DRIVER_OPTS="irq=4 io=0x3f8" #tergantung alamat dari serial
setserial /dev/ttyS0 uart none 

#Chosen IR Transmitter
TRANSMITTER="None"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER=""
TRANSMITTER_DEVICE=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""

#Enable lircd
START_LIRCD="true"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD="false"

#Try to load appropriate kernel modules
LOAD_MODULES="true"

# Default configuration files for your hardware if any
LIRCMD_CONF=""

#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to "false"
FORCE_NONINTERACTIVE_RECONFIGURATION="false"
START_LIRCMD=""

perbaiki file lircd, ketik:

sudo nano /etc/lircd.conf

tambahkan baris:

include “/usr/share/lirc/remotes/sharp/G1324SA” #sesuaikan dengan letak file conf remote

OK, sekarang reboot Lanjutkan dengan cek modul, ketik:

lsmod | grep lirc

ps ax | grep lirc

jika ada tulisan: /usr/sbin/lircd berarti sudah ok lakukan cek dengan irw, ketik:

irw

lalu pencet remote. Jika ada keterangan tombol yang dipencet berarti OK.

Saran:

Instal gedit, editor text grafis,biar edit file conf mudah (perlu konesi internet)  ketik:

sudo apt-get update

sudo apt-get install gedit

Troubleshoot:

1. Jika ada tulisan Cannot open /dev/ttyS0: permision denied berarti seting tty salah

2. Jika pada saat irw tidak keluar apa-apa, file conf remote salah, buat baru: Matikan lirc, ketik:

sudo -s

/etc/init.d/lirc stop

irrrecord –driver=default –device=/dev/lircd0 Remotku –disable-namespace

lalu ikuti petunjuk, hingga diminta set nama tombol pada saat tulisan please enter name bla bla bla. isikan nama tombol, misalnya POWER dan tekan tombol power pada remote. Ikuti dengan tombol lain dan terakhir tekan enter saja. copy hasil konfigurasi ke dir remote

cp Remotku /usr/share/lirc/remotes/

ganti alamat konfigurasi file hardware.conf dan lircd.conf dari /sharp/G1324SA menjadi Remoteku jalankan lirc kembali, ketik

/etc/init.d/lirv start -v

exit

irw

harusnya sudah muncul tombolnya! tekan ctrl+c untuk keluar

Konfigurasi XBMC

edit file lirc, ketik:

sudo nano /usr/share/xbmc/system/Lircmap.xml

Tambahkan:

<remote device=”sharp”>
<power>POWER</power>
<select>TV/VIDEO</select>
<one>1</one>
<two>2</two>
<three>3</three>
<four>4</four>
<five>5</five>
<six>6</six>
<seven>7</seven>
<eight>8</eight>
<nine>9</nine>
<zero>0</zero>
<up>VOL+</up>
<down>VOL-</down>
<left>CH-</left>
<right>CH+</right>
<play>MENU</play>
<mute>MUTE</mute>
</remote>