Search code examples
androidandroid-studiosha

easiest way to get sha256 of mobile apps


Am trying to find a way to get SHA256 of a mobile app,i have search around but i didn't understand some of the things i came across. i tried

  MessageDigest md = MessageDigest.getInstance("SHA");

 try {
     md.update(toChapter1);
     MessageDigest tc1 = md.clone();
     byte[] toChapter1Digest = tc1.digest();
     md.update(toChapter2);
     ...etc.
 } catch (CloneNotSupportedException cnse) {
     throw new DigestException("couldn't make digest of partial content");
 }

and also if you can explain the concept i will be glad


Solution

  • i found a Hashing Library at android arsenal and its very easy,simple and just one line of code. can hash MD5, SHA-1, SHA-256, SHA-384, or SHA-512.

    1.first add this to your gradle and sync

    implementation 'com.github.1AboveAll:Hasher:1.2'

    1. Start hashing...

    Hasher.Companion.hash("Hello",HashType.SHA_1);