Featured Security Tools

TRIPLE DES Encryption/Decryption Online Tool

Triple DES Encryption and Decryption Online

What is TRIPLE DES?

In cryptography, Triple DES (3DES), officially the Triple Data Encryption Algorithm (TDEA or Triple DEA), is a symmetric-key block cipher. This cipher which applies the Data Encryption Standard (DES) cipher algorithm three times to each data block.

The original DES cipher’s key size of 56 bits was generally sufficient when that algorithm was designed. But, the availability of increasing computational power made brute-force attacks feasible.

Triple DES provides a relatively simple method of increasing the key size of DES to protect against such attacks, without the need to design a completely new block cipher algorithm.

You can try here our TRIPLE DES Encryption Online Tool . And here you can try our TRIPLE DES Decryption Online Tool

Triple DES Encryption PHP Sample of use

function encrypt($data, $secret)
{
//Generate a key from a hash
$key = md5(utf8_encode($secret), true);

//Take first 8 bytes of $key and append them to the end of $key.
$key .= substr($key, 0, 8);

//Pad for PKCS7
$blockSize = mcrypt_get_block_size('tripledes', 'ecb');
$len = strlen($data);
$pad = $blockSize - ($len % $blockSize);
$data .= str_repeat(chr($pad), $pad);

//Encrypt data
$encData = mcrypt_encrypt('tripledes', $key, $data, 'ecb');

return base64_encode($encData);
}
$key = "1234";
$str = "Hello"; 
echo "The string: ".$str;
echo encrypt($str,$key);

Triple DES Decryption PHP Sample of use

function decrypt($data, $secret)
{
//Generate a key from a hash
$key = md5(utf8_encode($secret), true);

//Take first 8 bytes of $key and append them to the end of $key.
$key .= substr($key, 0, 8);

$data = base64_decode($data);

$data = mcrypt_decrypt('tripledes', $key, $data, 'ecb');

$block = mcrypt_get_block_size('tripledes', 'ecb');
$len = strlen($data);
$pad = ord($data[$len-1]);

return substr($data, 0, strlen($data) - $pad);
}
$key = "1234";
$str = "Hello"; 
echo "The string: ".$str;
echo encrypt($str,$key);


Comments   

Leave a Comment

You may also like

loading...