开发者

Different MD5 with as3corelib

I'm trying to md5 some file with as3corelib, but if I compare the as3 hash with a php one, I get different strings.

That's what I do:

_loader = new URLLoader();
_loader.load( new URLRequest( "image.jpg" ) );
_loader.addEventListener( Event.COMPLETE, completeHandler );

private function completeHandler( event:Event ):void {
       var data:ByteArray = new ByteArray(); 
       data.writeUTFBytes( _loader.data );
       var hash:MD5Stream = new 开发者_高级运维MD5Stream();
       trace(hash.complete(data));
}

I've already googled for this issue, finding this post where a similar thing is discussed (making an hash of a string).

Any idea?


Try to set the loader dataFormat property to URLLoaderDataFormat.BINARY prior to the load() call:

_loader = new URLLoader();
_loader.dataFormat = URLLoaderDataFormat.BINARY;
_loader.load( new URLRequest( "image.jpg" ) );
_loader.addEventListener( Event.COMPLETE, completeHandler );

private function completeHandler( event:Event ):void {
       var hash:MD5Stream = new MD5Stream();
       trace(hash.complete(_loader.data));
}

Then use directly the _loader.data variable since now it's a ByteArray

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜