DES


The DES(Data Encryption Standard) is a symmetric key algorithm. And the triple DES gives stronger data security because it performs DES operation 3 times. There are ECB and CBC methods in the DES.

The following is the ECB data encryption/decryption algorithm.

This command is for initializing PHPoC's DES crypto engine. So this command should be executed prior to the encryption/decryption operation. This command returns a context which is used for encryption and decryption.

Parameter Description
ecb/ede3_ecb ecb - DES ECB
ede3_ecb - 3DES ECB
enc/dec enc - encryption
dec - decryption
$ecb_key 64 bits-key to be used during the ECB encryption and decryption


The DES encryption or decryption is performed with this command. It returns the data which was encrypted or decrypted.

Parameter Description
$des the context when the crypto engine was initialized
$text plain text to be encrypted or cipher text to be decrypted

The following is an example of the ECB-based DES encryption and decryption.

// encryption
$des = system("des init ecb enc %1", $ecb_key);  // initialize
$out = system("des crypt %1 %2", $des, $ecb_pt); // encryption

// decryption
$des = system("des init ecb dec %1", $ecb_key);  // initialize
$out = system("des crypt %1 %2", $des, $ecb_ct); // decryption

The following is an example of the ECB-based triple DES encryption and decryption.

// encryption
$des = system("des init ede3_ecb enc %1", $ecb_key);
$out = system("des crypt %1 %2", $des, $ecb_pt);

// decryption
$des = system("des init ede3_ecb dec %1", $ecb_key);
$out = system("des crypt %1 %2", $des, $ecb_ct);


The following is CBC data encryption/decryption algorithm.

This command is for initializing PHPoC's DES crypto engine. So this command should be executed prior to the encryption/decryption operation. This command returns a context which is used for encryption and decryption.

Parameter Description
cbc/ede3_cbc cbc - DES CBC
ede3_cbc - 3DES CBC
enc/dec enc - encryption
dec - decryption
$cbc_key 64 bits-key to be used during the ECB encryption and decryption
$iv 64 bits initialization vector


The DES encryption or decryption is performed with this command. It returns the data which was encrypted or decrypted.

Parameter Description
$des the context when the crypto engine was initialized
$text plain text to be encrypted or cipher text to be decrypted

The following is an example of the CBC-based DES encryption and decryption.

// encryption
$des = system("des init cbc enc %1 %2", $cbc_key, $cbc_iv);  // initialize
$out = system("des crypt %1 %2", $des, $cbc_pt);             // encryption

// decryption
$des = system("des init cbc dec %1 %2", $cbc_key, $cbc_iv);  // initialize
$out = system("des crypt %1 %2", $des, $cbc_ct);             // decryption