This is a something like signinig report's my app:
Variant: release
Config: config
Store: C:\Users\Superman\Desktop\web.jks
Alias: web
MD5: 8C:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
SHA1: D3:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
SHA-256: A0:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
Valid until: Sunday, December 4, 2044
Is there a way to get this code(MD5, SHA1, SHA-256) through Android programming? I want to save one of them on the server. When using the app, these values should be checked with the values stored in the server, if it is not equal exit and kill the process (I do this to prevent my app from cracking)
This answer it taken from another answer Check out this function
// key like: SHA1, SHA256, MD5.
private fun get(key: String, info: PackageInfo) {
try {
for (signature in info.signatures) {
val md: MessageDigest = MessageDigest.getInstance(key)
md.update(signature.toByteArray())
val digest: ByteArray = md.digest()
val toRet = StringBuilder()
for (i in digest.indices) {
if (i != 0) toRet.append(":")
val b: Byte = digest[i] and 0xff.toByte()
val hex = Integer.toHexString(b.toInt())
if (hex.length == 1) toRet.append("0")
toRet.append(hex)
}
Log.d(TAG, "key: $key $toRet")
}
} catch (e1: PackageManager.NameNotFoundException) {
Log.e(TAG, e1.toString())
} catch (e: NoSuchAlgorithmException) {
Log.e(TAG, e.toString())
} catch (e: Exception) {
Log.e(TAG, e.toString())
}
}
To use it call it like this
get("SHA1", packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES))