[Droid Eris Android Development] scary alien:
[How To] Verify a File's Integrity

Captainkrtek, is this what you had in mind?

Thanks!

=============================================================

[How To] Verify a File's Integrity

Its always a good idea to validate a file's size and checksum before and after you download it (and after placing it on your /sdcard). Reputable sites/sources should publish a file's size and some type of checksum (either MD5 or SHA1) for the files hosted there. Beware of those that do not. Verifying the checksum of the file that you've downloaded ensures that you have a full, complete, and uncorrupted version of the file.

Additionaly, developers are highly encouraged to publish their ROM's (or whatever file they produce) file size and checksum [reference: http://xdaforums.com/showthread.php?t=769587]

After obtaining the information about a given file's checksum, its always a good idea to check it when its ultimately placed on your phone since every transfer point along the way (i.e, another computer), is an opportunity for an incomplete or corrupted file.

Checking Directly On Your Phone

There are now several ways to check a file's size and checksum on your phone:

1. Astro File Manager (free in the Market); long-press a filename, select 'Details' (for very large files, you might have to wait a few seconds for the MD5 checksum to be displayed)

2. ManD5 Lite (free in the Market); select your file and it will calculate and display that file's MD5 checksum

3. View attachment MD5-Checksum-v2.2.apk; this free app can calculate MD5 and SHA1 checksums for a selected file. Additionally, it has jar-file verification features (i.e., for custom ROMs, .apks, and true .jar files) than can be used to perform SHA1 checksum verification of each file in a jar against the SHA1 checksum listed in its manifest.

4. Some rooted phones might have busybox-type support for an md5sum utility that you can run on your phone. Use something like Android Terminal Emulator (free in the Market) and type: md5sum filename (substituting, of course, your file's full pathname for filename). You can also launch the phone's md5sum utility (if applicable) via an Android SDK's "adb shell" session.

Checking from Windows

To check a file's checksum on you Windows PC, you'll need a checksum utility:

1. Microsoft has an unsupported utility, the File Checksum Integrity Verifier (fciv) [available here http://support.microsoft.com/kb/841290]. This very versitile utility can calculate both MD5 and SHA1 checksums against one or more files at a time. Here are a few example commands:

[COLOR="blue"][B]fciv -md5 c:\temp\myfile.zip
fciv -sha1 c:\temp\myfile.zip
fciv -both c:\temp\myfile.zip[/B][/COLOR]

2. There are also various other freeware checksum utilities, a few of which are available from here: http://www.md5summer.org/download.html

I typically use the version entitled DOS Command line MD5sum utility since I'm comfortable with the Windows Command Prompt. I've tried the non-command prompt (window) version of the app, but I find it a little unwieldy.

To install and use the command line version:

A. In the browser of your (Windows) PC, navigate to http://www.md5summer.org/download.html

B. About three-fourths of the way down the page, find the DOS Command Line MD5sum utility

C. Right-click and download this version (should be http://www.md5summer.org/md5sum.zip)

D. After downloading, extract the md5sum.exe file to a meaningful place on your PC's hard drive

E. To run it, just launch the Windows Command Prompt and change (cd) to the directory where the file was extracted to [note: more Windows-savvy users will place the extract file into a directory that is already referenced by their PATH variable or will update the PATH variable to include the extracted file's location].

F. Example command: md5sum.exe c:\temp\myfile.zip

Checking from a Mac (courtesy of Android Forum's doogald)

Things are a bit easier from a Mac, since there is no utility that you need to find or download.

To check from the Terminal on a Mac:

1. Optionally change your directory to the location of the file to be checked. For example: cd ~/Downloads

2. Use the openssl command to calculate a file's checksum. For example: openssl md5 pathtofile

Alternate method (courtesy of 5thAgent / doogald):

- navigate the Finder so that the file is visible

- open a Terminal window

- type openssl md5 and a space

- from the Finder, drag your file onto the Terminal window (the file's full pathname will be automatically added to the end of the 'openssl md5' command)

- return to the Terminal window and press the 'return' key

- note: you can replace the md5 option with sha1 to obtain an SHA1 checksum

Acknowledgements

1. Thanks to XDA's bftb0 (Android Forum's erisuser1) for continually espousing the benefits of checking one's file's integrity (a small part of his continued contributions to the Android community)

2. Thanks also to Android Forums doogald for the same and for suggesting fciv and how to use openssl

Related threads and posts

http://androidforums.com/htc-droid-eris/138831-verify-your-files-md5-checksums.html

http://xdaforums.com/showthread.php?t=769587

http://androidforums.com/eris-all-things-root/168942-phone-rom-checksum-verifier.html

http://androidforums.com/all-things-root-eris/127861-universal-eris-root-dummies-7.html#post1296149

http://support.microsoft.com/kb/841290

http://download.microsoft.com/download/c/f/4/cf454ae0-a4bb-4123-8333-a1b6737712f7/windows-kb841290-x86-enu.exe