This code returns the SHA-1 hash of the signing key certificate used to sign the APK.
It is the same value that you can see under Tools - Private Sign Key:
You can use it to test whether someone has rebuilt your app and signed it with his own key.
It depends on: JavaObject, Encryption and ByteConverter libraries.
Tags: apk signature, sha-1, hash
It is the same value that you can see under Tools - Private Sign Key:
You can use it to test whether someone has rebuilt your app and signed it with his own key.
B4X:
Sub GetSignatureHash As String
Dim jo As JavaObject
jo.InitializeContext
Dim signatures() As Object = jo.RunMethodJO("getPackageManager", Null).RunMethodJO("getPackageInfo", _
Array (Application.PackageName, 0x00000040)).GetField("signatures")
Dim sig As JavaObject = signatures(0)
Dim md As MessageDigest
Dim hash() As Byte = md.GetMessageDigest(sig.RunMethod("toByteArray", Null), "SHA-1")
Dim bc As ByteConverter
Dim raw As String = bc.HexFromBytes(hash)
Dim sb As StringBuilder
sb.Initialize
For i = 0 To raw.Length - 2 Step 2
sb.Append(raw.CharAt(i)).Append(raw.CharAt(i + 1)).Append(":")
Next
sb.Remove(sb.Length - 1, sb.Length)
Return sb.ToString
End Sub
It depends on: JavaObject, Encryption and ByteConverter libraries.
Tags: apk signature, sha-1, hash