不同的MD5用的as3corelib [英] Different MD5 with 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 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搜索这个问题,发现这个<一href="http://stackoverflow.com/questions/3581242/md5-hash-in-c-doesnt-match-md5-hash-in-action-script">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
这篇关于不同的MD5用的as3corelib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!