Reputation: 195
I am creating a Sha1 checksum for an apk file in Mac as well as windows. I use the same file while in mac I use this
cat AppName.apk |openssl dgst -binary -sha1 | openssl base64 | tr '+/' '-_' |tr -d '='
// I get 7pF3C4YCqMHKXOzOep_DW1feJxE
In Windows I use various methods mentioned here and all of them generate the same checksum.
ee91770b8602a8c1ca5cecce7a9fc35b57de2711
Why is it different if it is sha1 hash of the same file? or the hash can be both of this? I am confused here. Can anyone explain?
Upvotes: 1
Views: 3283
Reputation: 4009
The command you use on the Mac does encode the checksum in base64 (which is very uncommon) while on Windows you are encoding the checksum as hex digits.
You can create the SHA-1 checksum on a file using the shasum
command of OS X:
shasum AppName.apk | sed -e 's/ .*//'
(The piped call to sed is optional and just serves to remove the filename which is normally added by shasum after the output of the checksum.)
You can even verify that basically both platforms calculated the same checksum and just encoded it differently by transcoding from Base64 to Hex:
echo 7pF3C4YCqMHKXOzOep_DW1feJxE= | base64 -D| hexdump
Results in:
0000000 ee 91 77 0b 86 02 a8 c1 ca 5c ec ce 7a 9f c3 5b
0000010 57 de 27 11
Which is the checksum you got on Windows.
Upvotes: 5