Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function String2Hex($string){
- $hex='';
- for ($i=0; $i < strlen($string); $i++){
- $hex .= dechex(ord($string[$i]));
- }
- return $hex;
- function Hex2String($hex){
- $string='';
- for ($i=0; $i < strlen($hex)-1; $i+=2){
- $string .= chr(hexdec($hex[$i].$hex[$i+1]));
- }
- return $string;
- }
- function PKCS5AddPadding($input) {
- $pad = strlen($input) % 16;
- for ($i = $pad; $i < 16; $i++) {
- $input .= chr(16 - $pad);
- }
- return $input;
- }
- function PKCS5RemovePadding($input) {
- return rtrim($input, substr($input, strlen($input) - 1, 1));
- }
- function kn_dec($ciph,$key) {
- $cipherText = base64_decode($ciph);
- $plainText = PKCS5RemovePadding(mcrypt_decrypt(MCRYPT_RIJNDAEL_128,$key, $cipherText, MCRYPT_MODE_CBC));
- return $plainText;
- }
- function kn_enc($plai,$key) {
- $plainText = $plai;
- $cipherText = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, PKCS5AddPadding($plainText), MCRYPT_MODE_CBC);
- $cipherText = base64_encode($cipherText);
- return $cipherText;
- }
- if (isset($_POST['te'])) {
- die(String2Hex(kn_enc($_POST['te'],'!(*@&#^$%!&%^&*@')));
- } else if (isset($_POST['td'])) {
- die(kn_dec(Hex2String($_POST['td']),'!(*@&#^$%!&%^&*@'));
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement