Lorenz,<div><br></div><div>Well, I've experimented with ByteArray.writeUTFBytes( 'testtest' ) to avoid the Hex utility library and it's given me the same results.</div><div><br></div><div>I don't think that is the issue, if you have pycrypto installed would you be able to run the code to encrypt and base64 the string? You could copy and paste it verbatim into idle, wouldn't be much work at all and it would really help me out if I knew what the expected output of the python library should be.</div>
<div><br></div><div>Thanks</div><div>Joshua<br><br><div class="gmail_quote">On Wed, Jan 12, 2011 at 11:45 AM, Lorenz Quack <span dir="ltr"><<a href="mailto:don@amberfisharts.com">don@amberfisharts.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hey Joshua,<br>
<br>
I haven't used as3crypto (or any as3 for that matter) nor the pycrypto.blowfish. So basicly I'm just wildly guessing<br>
here. I was wondering if you made sure that this "Hex" thing in your as3 code isn't messing up things?<br>
because in you base64 test you don't use that.<br>
<br>
cheers,<br>
//Lorenz<br>
<div><div></div><div class="h5"><br>
<br>
On 01/12/2011 08:07 PM, Joshua Strauss wrote:<br>
> I'm trying to use symmetric encryption to pass data from actionscript 3 (client) to python (server).<br>
><br>
> The libraries I'm using are as3crypto and pycrypto.<br>
><br>
> I'm not sure if I'm using these libraries correctly, here's the action script 3 code.<br>
><br>
> private function testOnInit():void {<br>
> var t_toEnc:String = 'testtest';<br>
> var t_byAry:ByteArray = Hex.toArray( Hex.fromString( t_toEnc ) );<br>
> var t_key:ByteArray = Hex.toArray( Hex.fromString( 'Thisisthekey' ) );<br>
> var t_cbc:CBCMode = new CBCMode( new BlowFishKey( t_key ), new NullPad );<br>
> var t_enc:String;<br>
> t_cbc.IV = Hex.toArray( '30313233' );<br>
> t_cbc.encrypt( t_byAry );<br>
> t_enc = Base64.encodeByteArray( t_byAry );<br>
> dbg( 'b64 encrypted string ' + t_enc ); //this is just a debugging function we use in our code.<br>
> }<br>
><br>
> This is the base64 encoded output of the function above.<br>
><br>
> xvVqLzV5TU4=<br>
><br>
> Now, using the same key, initialization vector, and algorithm from the pycrypto library gives me different output.<br>
><br>
> Here's the python code.<br>
><br>
> >>> from Crypto.Cipher import Blowfish<br>
> >>> B = Blowfish.new( 'Thisisthekey', Blowfish.MODE_CBC, '30313233' )<br>
> >>> S = 'testtest'<br>
> >>> X = B.encrypt( S )<br>
> >>> import base64<br>
> >>> Y = base64.b64encode( X )<br>
> >>> print Y<br>
><br>
> I82NQEkSHhE=<br>
><br>
> I'm pretty sure that I'm doing something wrong with the encryption process because I can base64 encode 'testtest' on<br>
> both libraries and receive the same output.<br>
><br>
> Here's as3<br>
><br>
> var b:ByteArray = new ByteArray();<br>
> b.writeUTFBytes( 'testtest' );<br>
> dbg( Base64.encodeByteArray( b ) );<br>
><br>
> Yields...<br>
><br>
> dGVzdHRlc3Q=<br>
><br>
> Here's the python<br>
><br>
> >>> T = 'testtest'<br>
> >>> print base64.b64encode( T )<br>
><br>
> Yields…<br>
><br>
> dGVzdHRlc3Q=<br>
><br>
> Could someone please encrypt and base64encode the same string with the same IV in either python or actionscript, so I<br>
> know which library is actually producing the correct output?<br>
><br>
> Any assistance with this problem would be greatly appreciated, I'm stuck and don't know how to proceed from here.<br>
><br>
> Thank you<br>
> Joshua<br>
><br>
<br>
</div></div>_______________________________________________<br>
pycrypto mailing list<br>
<a href="mailto:pycrypto@lists.dlitz.net">pycrypto@lists.dlitz.net</a><br>
<a href="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto" target="_blank">http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto</a><br>
</blockquote></div><br></div>