简体   繁体   中英

php perl cross-platform encoder/decoder

it used to be that the perl encoder

use Crypt::CBC;
$cipher= Crypt::CBC->new( {'key' => $cipherkey,
             'cipher'=> 'Blowfish',
             'iv' => '12345678',
             'regenerate_key' => 0,
             'padding' => 'null',
             'prepend_iv' => 0
            });

could be nicely decrypted by the php function

mcrypt_cbc(MCRYPT_BLOWFISH, $key, base64_decode($v), MCRYPT_DECRYPT, '12345678')

alas, mcrypt_cbc is not only deprecated now, it also disappeared from php7 altogether.

is there a recommended encoder in perl that the standard new php decoder mcrypt_encrypt works with?

for my purposes, I do not need to be super-secret. reasonably secret is ok. no life-or-death secrets. if it takes half an hour to decode, it's good enough. ideally, I would use whatever the canonical security encoder decoder is (as long as they are compatible, of course).

advice appreciated.

The docs point out you should use mcrypt_decrypt instead. It appears PHP is phasing out mcrypt_cbc in favour of a more generic interface. The following provides the same functionality:

mcrypt_decrypt(MCRYPT_BLOWFISH, $key, base64_decode($cipher_base64), MCRYPT_MODE_CBC, $iv)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM