vishnugupta11 / js-mcrypt

Automatically exported from code.google.com/p/js-mcrypt
0 stars 0 forks source link

Request Twofish #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

do you integrate Twofish?

http://ats.oka.nu/titaniumcore/js/crypto/Cipher.sample.html

This sample works for me with mcrypt. 

Here my PHP Code:

**************

<?php

/**
 * @author Josef Fröhle
 * @copyright 2012
 */

    $iv_size = mcrypt_get_iv_size(MCRYPT_TWOFISH, MCRYPT_MODE_CBC);
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    $key = base64_decode('IDJkKkhBcyxWKDdWMzpgcjU3Vj4sWylsSStORkclfWM=');
    $text = "Meet me at 11 o'clock behind the monument.";
    echo base64_encode($key) . "\r\n";

    $crypttext = mcrypt_encrypt(MCRYPT_TWOFISH, $key, $text, MCRYPT_MODE_CBC, $iv);
    echo base64_encode($iv.$crypttext) . "\r\n";

    $text = "reSz4nYwvUn2bCivKpNxRcausJ71JQHsGvoIKUc2Nvdl+nUw
OtHPPV2sqU7TyS+tg1eBeuxVzf6nvbn3J9yWlA==";
    $text_enc = base64_decode($text);
    $iv = substr($text_enc,0,16);
    echo strlen($iv) . "\r\n";
    $text = substr($text_enc,16);
    $crypttext = mcrypt_decrypt(MCRYPT_TWOFISH, $key, $text, MCRYPT_MODE_CBC, $iv);
    echo $crypttext;
?>

Original issue reported on code.google.com by josef.fr...@googlemail.com on 12 Dec 2012 at 8:57

GoogleCodeExporter commented 9 years ago

Original comment by FrederickDoering on 11 Dec 2014 at 7:54