[pycrypto] Base64 encoded output differs from pycrypto and as3crypto libraries.

Joshua Strauss joshua.a.strauss at gmail.com
Wed Jan 12 16:18:55 CST 2011


To all who gave me some of their time.

I've sorted the problem, it was how the IV was being fed into the byte array
in AS3.

Thank you all for your help :)

Regards,
Joshua

On Wed, Jan 12, 2011 at 1:49 PM, Joshua Strauss
<joshua.a.strauss at gmail.com>wrote:

> Legrandin,
>
> I think you are on to something here. Removing the initialization vector
> from both pycrypto and as3crypto produces the same b64encoded output. I've
> been playing around with different IV's but I can only get the output to
> match without the presence of an IV.
>
> This does lead me to believe that the IV is the source of my problem but if
> anyone can think of a reason why this might not be, it would be helpful to
> know as I don't want to be on the wrong track.
>
> I haven't done much coding at the byte level (I'm mainly a web developer,
> and not seasoned by any means), I'll keep trucking from here I suppose.
>
> Regards,
> Joshua
>
> On Wed, Jan 12, 2011 at 1:15 PM, Legrandin <
> gooksankoo at hoiptorrow.mailexpire.com> wrote:
>
>> >    var t_byAry:ByteArray = Hex.toArray( Hex.fromString( t_toEnc ) );
>> >    var t_key:ByteArray = Hex.toArray( Hex.fromString( 'Thisisthekey' )
>> );
>> >    var t_cbc:CBCMode = new CBCMode( new BlowFishKey( t_key ), new
>> NullPad );
>> >    t_cbc.IV = Hex.toArray( '30313233' );
>> >    t_cbc.encrypt( t_byAry );
>> >    t_enc = Base64.encodeByteArray( t_byAry );
>>
>> >    >>> from Crypto.Cipher import Blowfish
>> >    >>> B = Blowfish.new( 'Thisisthekey', Blowfish.MODE_CBC, '30313233' )
>>
>> Could it be that in you AS code your IV is 4 bytes (0x30,0x31,0x32,0x33)
>> which t_cbc.encrypt() silently pads, whereas in the python code it is 8
>> different bytes (0x33 for '3', 0x30 for '0', etc)?
>>
>> Legrandin
>>
>> _______________________________________________
>> pycrypto mailing list
>> pycrypto at lists.dlitz.net
>> http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.dlitz.net/pipermail/pycrypto/attachments/20110112/efd8b675/attachment-0001.htm 


More information about the pycrypto mailing list