0 ) && (strlen($this_key) > 0)){ $msg_data = encrypt_message($this_alog, $this_key, $cipher_mode, $msg_data, $debug); }; }; $msg_data = base64_encode($msg_data); // make the data so it can be displayed. $msg_data = chunk_split($msg_data); // this breaks the lines up into something manageable. }elseif($_POST[mode] == "decrypt"){ $msg_data = base64_decode($msg_data); // return to original binary mesage format. $count = $max_keys; while ($count > 0){ $this_alog = $_POST[alog][$count]; $this_key = $_POST[key][$count]; if ((strlen($this_alog) > 0 ) && (strlen($this_key) > 0)){ $msg_data = decrypt_message($this_alog, $this_key, $cipher_mode, $msg_data, $debug); }; $count--; }; $msg_data = base64_decode($msg_data); // return the data to original displayed form. }; // **************************************************************************************** // // These are our encryption functions // **************************************************************************************** // function encrypt_message($this_alog, $this_key, $this_mode, $curmsg, $debug){ // these don't work in anything but stream mode. if (("$this_alog" == "wake") || ("$this_alog" == "enigma") || ("$this_alog" == "arcfour")){ $this_mode = "stream"; }; $cipher = mcrypt_module_open($this_alog, '', $this_mode, ''); // Make Initialization Vector. If different IV's are used in encryption and decryption, // it will corrupt result. // This isn't terribly important to keep secret. $iv = str_pad($iv, mcrypt_get_iv_size($this_alog, $this_mode), "0"); // Adjust key for this cipher. $key_size = mcrypt_get_key_size($this_alog, $this_mode); $this_key = str_pad($this_key, $key_size, '0'); $this_key = substr($this_key, 0, $key_size); if ("$debug" == "1"){ print "** Encrypting with $this_alog :: $this_mode
Key($key_size) '$this_key'
"; }; // Encrypt message mcrypt_generic_init($cipher, $this_key, $iv); $newmsg = mcrypt_generic($cipher, $curmsg); mcrypt_generic_deinit($cipher); if ( (strlen($newmsg)< 1) || ($curmsg == $newmsg) || (md5($curmsg) == md5($newmsg)) ){ print "
Failed to encrypt data with $this_alog :: $this_mode
"; }else{ $curmsg = trim($newmsg, "\0"); }; return($curmsg); }; function decrypt_message($this_alog, $this_key, $this_mode, $curmsg, $debug){ // these don't work in anything but stream mode. if (("$this_alog" == "wake") || ("$this_alog" == "enigma") || ("$this_alog" == "arcfour")){ $this_mode = "stream"; }; $cipher = mcrypt_module_open($this_alog, '', $this_mode, ''); // Make Initialization Vector. If different IV's are used in encryption and decryption, // it will corrupt result. // This isn't terribly important to keep secret. $iv = str_pad($iv, mcrypt_get_iv_size($this_alog, $this_mode), "0"); // Adjust key for this cipher. $key_size = mcrypt_get_key_size($this_alog, $this_mode); $this_key = str_pad($this_key, $key_size, '0'); $this_key = substr($this_key, 0, $key_size); if ("$debug" == "1"){ print "** Decrypting with $this_alog :: $this_mode
Key($key_size) '$this_key'
"; }; // Decrypt Message mcrypt_generic_init($cipher, $this_key, $iv); $newmsg = mdecrypt_generic($cipher, $curmsg); mcrypt_generic_deinit($cipher); if ( (strlen($newmsg)< 1) || ($curmsg == $newmsg) || (md5($curmsg) == md5($newmsg)) ){ print "
Failed to decrypt data with $this_alog :: $this_mode
"; }else{ $curmsg = trim($newmsg, "\0"); }; return($curmsg); }; // Below is the HTML of the page, for the user to input the message, ciphers, and keys. ?> CryptMsg :: Cryptic Message Center
CryptMsg :: Cryptic Message Center
Version
SSL Cipher:

Encrypt Decrypt

 

"; }; ?>
AlgorithmKey
$key_count)