PDA

View Full Version : MD5 of first few bytes of a file



gagan.ddun
October 12th, 2009, 01:09 AM
Is it possible in flash using as3 that we read first few bytes from a file and calculate MD5 of it ?

Krilnon
October 12th, 2009, 01:21 AM
Yep!

Scythe
October 12th, 2009, 01:30 AM
Use a URLLoader, then use the data property to get the first few bytes.

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/URLLoader.html (http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/net/URLLoader.html)

gagan.ddun
October 12th, 2009, 05:45 AM
Basically I need to read a file using fileReference and then read 4096 bytes from start of file and 4096 from end of the file. Then find MD5 of these bytes. Is it possible?

file can be of any format (.mp3,.pdf,etc)

Swooter
October 12th, 2009, 08:40 AM
Yes that should be possible... but I think it's easier done server-side after the file is uploaded (I assume you upload, because you're using fileReference) So, in PHP for example, you can just read a chunk of data from the file, or use the md5_file function (PHP)