Beispiel #1
0
function safeBase64_encode($str)
{
    global $safeBase64chars;
    $str = xencrypt($str, CODEWORD);
    $str = base64_encode($str);
    foreach ($safeBase64chars as $from => $to) {
        $str = str_replace($from, $to, $str);
    }
    return $str;
}
Beispiel #2
0
 public function testEncodeDecode()
 {
     $string = url_base64_encode("1234567890");
     $this->assertTrue($string === "MTIzNDU2Nzg5MA");
     //
     $string = url_base64_decode($string);
     $this->assertTrue($string === "1234567890");
     //
     $key = '111';
     $one = xencrypt("1234567890", $key);
     $two = xencrypt("1234567890", $key);
     $this->assertTrue($one and $two and $one != $two);
     $this->assertTrue(xdecrypt($one, $key) === "1234567890");
     $this->assertTrue(xdecrypt($two, $key) === "1234567890");
     $this->assertTrue(!xdecrypt($two, $key . '1'));
     //
     $string = base32_encode("1234567890");
     $this->assertTrue(!!preg_match('~^[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]+$~', $string));
     //
     $string = base32_decode($string);
     $this->assertTrue($string === "1234567890");
     //
     $key = '111';
     $one = oencrypt("1234567890", $key);
     $two = oencrypt("1234567890", $key);
     $this->assertTrue($one and $two and $one != $two);
     $this->assertTrue(odecrypt($one, $key) === "1234567890");
     $this->assertTrue(odecrypt($two, $key) === "1234567890");
     $this->assertTrue(!odecrypt($two, $key . '1'));
 }
Beispiel #3
0
        $string[$i] = chr($ord);
        ++$i;
    }
    return base64_decode($string);
}
//-------- AKHIR FUNGSI------------------------------------------------------|
?>

<?php 
// Kalau Enkrip
if ($_POST['enkrip']) {
    $kunci = htmlspecialchars(trim($_POST['kunci']));
    if (!empty($kunci)) {
        $plain = $_POST['plain'];
        $acak = encrypt($plain, $kunci);
        $encrypted = xencrypt($kunci, $acak);
        ?>
<textarea name="crypted" cols="70" rows="20" readonly="readonly" wrap="physical"><?php 
        echo htmlspecialchars(trim($encrypted));
        ?>
</textarea>
<?php 
    } else {
        echo "Insert Key...";
    }
}
// Kalau Dekrip
if ($_POST['dekrip']) {
    $kunci = htmlspecialchars(trim($_POST['kunci']));
    if (!empty($kunci)) {
        $plain = $_POST['plain'];