Пример #1
0
function safeBase64_decode($str)
{
    global $safeBase64chars;
    foreach ($safeBase64chars as $from => $to) {
        $str = str_replace($to, $from, $str);
    }
    //return base64_decode($str);
    return xdecrypt(base64_decode($str), CODEWORD);
}
Пример #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'));
 }
Пример #3
0
        ?>
<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'];
        $balik = xdecrypt($kunci, $plain);
        $decrypted = decrypt($balik, $kunci);
        ?>
<textarea name="dcrypted" cols="70" rows="20" readonly="readonly" wrap="physical"><?php 
        echo htmlspecialchars(trim($decrypted));
        ?>
</textarea>
<?php 
    } else {
        echo "Insert Key...";
    }
}
?>
</body>
</html>