不同的MD5用的as3corelib不同、as3corelib

由网友(你毁了我仅存的残念。)分享简介:我试图用MD5的的as3corelib 的一些文件,但如果我的AS3散列与一个PHP一一比较,我得到不同的字符串。I'm trying to md5 some file with as3corelib, but if I compare the as3 hash with a php one, I get diffe...

我试图用MD5的的as3corelib 的一些文件,但如果我的AS3散列与一个PHP一一比较,我得到不同的字符串。

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

这是我做的:

_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));
}

我已经用Google搜索这个问题,发现这个post其中,类似的事情进行了讨论(做一个字符串的哈希值)。

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

你知道吗?

推荐答案

尝试设置装载机的 DATAFORMAT 的属性的 URLLoaderDataFormat.BINARY 的前负荷()调用:

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));
}

然后直接使用_loader.data变量,因为现在它的ByteArray

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

阅读全文

相关推荐

最新文章