Giter Club home page Giter Club logo

js-mcrypt's People

js-mcrypt's Issues

Request Twofish

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 [email protected] on 12 Dec 2012 at 8:57

Javascript error in IE8

The following code (in mcrypt.js) causes an error in IE8, and prevents the 
mcrypt library from loading.

var ciphers={          //      block size,     key size
  "rijndael-128"        :[      16,                     32],
  "rijndael-192"        :[      24,                     32],
  "rijndael-256"        :[      32,                     32],
  "serpent"             :[      16,                     32],
 }

The issue is the comma at the end of the "serpent" line. FF and Chrome ignore 
this syntax error and work correctly.

Original issue reported on code.google.com by [email protected] on 17 Sep 2013 at 1:33

Rijndael key padding does not match PHP's key padding

The Rijndael key padding used in mcrypt.js always pads the encryption key with 
0's (null) up to 32 bytes, but PHP's mcrypt functions pad the key up to the 
nearest valid key length (16, 24, or 32 bytes).

PHP exmaple:

<?php
//15 byte key
echo bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, 
hex2bin("387498719817984798740000000000"), "test string to encrypt", 
MCRYPT_MODE_ECB))."\n";
//16 byte key
echo bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, 
hex2bin("38749871981798479874000000000000"), "test string to encrypt", 
MCRYPT_MODE_ECB))."\n";
//17 byte key
echo bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, 
hex2bin("3874987198179847987400000000000000"), "test string to encrypt", 
MCRYPT_MODE_ECB))."\n";
//23 byte key
echo bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, 
hex2bin("3874987198179847987400000000000000000000000000"), "test string to 
encrypt", MCRYPT_MODE_ECB))."\n";
//24 byte key
echo bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, 
hex2bin("387498719817984798740000000000000000000000000000"), "test string to 
encrypt", MCRYPT_MODE_ECB))."\n";
//25 byte key
echo bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, 
hex2bin("38749871981798479874000000000000000000000000000000"), "test string to 
encrypt", MCRYPT_MODE_ECB))."\n";
?>

Output:

e544da48ce56ace9b74e7267cecc867bf87b275202419a5ab4ce2a59ab63c75c
e544da48ce56ace9b74e7267cecc867bf87b275202419a5ab4ce2a59ab63c75c
ef4c7f8811e758b6c9b0955e91163d8850e0259979571ef0f1b3a5417b448699
ef4c7f8811e758b6c9b0955e91163d8850e0259979571ef0f1b3a5417b448699
ef4c7f8811e758b6c9b0955e91163d8850e0259979571ef0f1b3a5417b448699
d49d2edc6937eb50765a508d2d4b6b74d4fc2851f41c81e733a7fe5fc0ed550f

This padding behavior occurs regardless of the rijndael algorithm (128 vs 192 
vs 256) and ragardless of the block cipher mode (ECB vs CBC).

Tested on PHP 5.0.4 through 5.5.0.

Original issue reported on code.google.com by [email protected] on 17 Sep 2013 at 1:57

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.