Tyler Longren wrote:

> Hi,
>
> I haven't written anything in perl for quite some time, so I'm pretty rusty.
> Does anyone have a perl version of this PHP code:
>
> function encrypt($string, $key) {
>  // version 2.4.x of lib mcrypt
>  $td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, "");
>  $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
>  mcrypt_generic_init ($td, $key, $iv);
>  $crypted = mcrypt_generic ($td, $string);
>  mcrypt_generic_end ($td);
>  return bin2hex($crypted);
> }
> function decrypt($string, $key) {
>  //version 2.4.x of lib mcrypt
>  $string = hex2bin($string);
>  $td = mcrypt_module_open (MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, "");
>  $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
>  mcrypt_generic_init ($td, $key, $iv);
>  $decrypted = mdecrypt_generic ($td, $string);
>  mcrypt_generic_end ($td);
>  return trim($decrypted);
> }
>
> Thanks,
> Tyler

Hi Tyler,

If you are interested in translating this PHP code into Perl, you can probably get a 
lot of help here.

First things first, you will need to generate a plain-language description of what the 
purpose of the program is, and what role each token or operator in the PHP code plays 
in fulfilling that purpose.  Then scan through the code to see what differences in 
syntax or available library functions would make this code incompatible with Perl.  
Make adaptations for those and voila! you're done.

When you run into specific issues in this project, send the error messages, some 
description of what you're trying to accomplish, and the code no the line cited in the 
error message and just before.  Please mark the specific line your error message 
refers to.

HTH,

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to