Question about getting an Android hashie

Asked 2 years ago, Updated 2 years ago, 16 views

PackageInfo info = ctx.getPackageManager().getPackageInfo(getAppPackageName(ctx), PackageManager.GET_SIGNATURES);

Doesn't the above statement mean to get the app's unique sign value?

Is it wrong that I understand?

It was a measure to encrypt md with the obtained sign value and use the secret key of aes...

How come if the project has that function, they'll all the same results...It's a mental breakdown ;;

I understood the encryption part, but I'm asking because the above two lines seem to be misunderstanding.

Masters! I'd appreciate it if you could give me an answer.

Below is the full text of the hashish import function created by someone.

/**

*/

public static String getPackageHashKey(Context ctx) {

try {

PackageInfo info = ctx.getPackageManager().getPackageInfo(getAppPackageName(ctx), PackageManager.GET_SIGNATURES);

for (Signature signature : info.signatures) {

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

md.update(signature.toByteArray());

return Base64.encodeToString(md.digest(), Base64.DEFAULT);

}

} catch (PackageManager.NameNotFoundException ex) {

ex.printStackTrace();

} catch (NoSuchAlgorithmException ex) {

ex.printStackTrace();

} catch (Exception ex) {

ex.printStackTrace();

}

return null;

}

android

2022-09-21 18:19

1 Answers

You're right to understand the concept. However, you said you were in a mental breakdown because everyone returned the same value. This could be the case. If APK and BAPK have the same value, the two projects signed with the same key.

If you don't have a special setting, the IDE will sign with the generated debug key, which will result in the same result. So you need to make sure you're not building in debug mode. If you signed with the same release key in the release build, the getPackageHashKey() function of the code you uploaded will return the same value.


2022-09-21 18:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.