4

I get files like this below:

GT-I5500-CSC-SERJK1.tar.md5

This is what I want:

GT-I5500-CSC-SERJK1.tar 

How can I get it? Can I just remove the md5 file extension?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
louxiu
  • 2,830
  • 3
  • 28
  • 42

6 Answers6

17

From what I understand this is a simple means of adding a checksum onto a tar file. Since the tar standard states that the end of the tar file is two successive blank "entries" in a row, all data past that point is ignored by "tar -x". So the android dev community has apparently taken to simply concatting the output of md5 to the end of this file.

The following bash script can be used to validate a ".tar.md5" file:

#! /bin/bash

check_tar_md5 () {
    local file="${1:?Required: file to check}"
    [[ ! -f "$file" ]] && {
            echo "File not found: $file" >&2
            return 1
    }
    local filename="$(basename "$file")"
    if [ "${filename##*.}" = md5 ]; then filename="${filename%.*}"; fi;
    local md5_line_length=$(printf "%032d *%s\n" 0 "$filename" | wc -c)
    local embedded_md5=$(tail -c $md5_line_length "$file" | ( read md5 rest; echo $md5 ) )
    local actual_md5=$(head -c -$md5_line_length "$file" | md5sum | ( read md5 rest; echo $md5 ) )
    if [ $embedded_md5 = $actual_md5 ]; then
            echo "$file: OK"
    else
            echo "$file: FAILED"
            return 1
    fi
}

[[ ! -z "$1" ]] && check_tar_md5 "$1"

If you 'source' this script you will have a 'check_tar_md5' function in your current env; otherwise you can just execute it; in either case you provide the file as the only argument. Output is similar to the "md5sum --check" utility.

Making the script more robust (e.g.: in the event you provide a file that is not a .tar.md5) is left as an exercise to the reader.

beltorak
  • 461
  • 3
  • 5
8

.tar.md5 files are generally used by Odin to flash firmware to android phones. They are essentially tar compressed archives with the md5 checksum appended to the end, so you can verify no data was corrupted.

md5 files usually are md5 checksums, but not in this special case.

johannestaas
  • 1,175
  • 1
  • 9
  • 15
4

The file a.tar.md5 contains the MD5 hash of the file a.tar. The tar and the md5 files are totally different files. You can not get a tar file from a tar.md5 file.

Edit: it turns out there are two types of .tar.md5 files:

  • Just MD5 sum. A file of 32 bytes. It is typically in a directory along with a .tar file, such as here. It is not possible to reconstruct the original tar file from the md5 file.
  • A tar archive with an appended MD5-sum. Several megabytes. Can be extracted by the standard tar tool, or it can be written to a phone with ODIN.
Sjoerd
  • 74,049
  • 16
  • 131
  • 175
  • sjoerd Thank you for your quick replay. Do you mean that the xxx.md5 don't contain the actual file that i need? Is xxx.md5 just used for verify? But the file size is 20M. – louxiu Apr 13 '11 at 09:46
  • Actually it is almost the same size as the file i want to get. – louxiu Apr 13 '11 at 09:51
  • @LouXiu - why don't you look into both files? Or use any visual diff that can compare binaries (e.g. Beyond Compare)? Normally, an .md5 file contains an md5 string and possibly a file name (or a list of those); it shouldn't be larger than some 100 bytes. In your case it is probably a user error either during download or during upload.. – atzz Apr 13 '11 at 10:10
  • Hi atzz, i don't have the file i want. But i just guess. The file i get is I5500XWJK3-CSC-SERJK1.rar. It is 115.7 MB. The i extract it. I get I5500XWJK3 directory that contain several xxx.tar.md5 files. I want to use them to flash my i5500 android phone. I get it from http://www.filecrop.com/I5500XWJK3.html – louxiu Apr 13 '11 at 10:26
  • @LouXiu - well, I think you better ask those who put the files there. Failing that, you can just try to use this file as if it was a .tar, and see if it fails. Or you can try to untar it and see what the archiver has to say. Also, a standard tar archive should have characters `ustar` at offset 0x101. – atzz Apr 13 '11 at 11:20
  • @atzz you are right. I just remove the .md5 extension. It works. I thought it may be a new file format, because i found some other guys also come up with this problem. – louxiu Apr 14 '11 at 03:43
3

a .tar.md5 file can be flashed to a samsung phone using the software program ODIN

Anthony Hatzopoulos
  • 10,437
  • 2
  • 40
  • 57
karl
  • 39
  • 1
0

Either the md5 # is the encrypted .tar file name or it is the encrypted .tar file. First you must decrypt the tar file to see its name.

-2

if you have downloaded it to your smartphone that is runing android OS then you can try this go to File Manager and then go to directory where the file you downloaded is located and hold your finger on the file you downloaded then the windows with some options should pop up and chose the rename option then delete where it says .md5 and you are done.

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304