MD5:Java 7及更高版本中keytool.exe的输出差异 [英] MD5: Difference in output of keytool.exe in Java 7 and above

查看:92
本文介绍了MD5:Java 7及更高版本中keytool.exe的输出差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下主题中提出了自己的担忧:

I have raised my concerns in the following thread:

如何在jdk.7.o中获取MD5哈希?

和类似的线程:

如果已安装Java 8,则无法使用Java 7安装

我还研究了:

https://docs.oracle.com/cd/E74665_01 /MOSHP/settings.htm#CIHEFHEF

但没有用.

由于我正在使用JRE/JDK版本> 10,因此无法使用keytools从我选择的任何密钥库中获取MD5.据说,如果我的JRE版本是7,则可以从密钥库中获取MD5.

Since I am using JRE/JDK version > 10, I am unable to obtain MD5 from any keystore of my choice using keytools. It is said that MD5 can be obtained from the keystore, if my JRE version is 7.

此外,我已经尝试并知道,当在Android Studio或Eclipse中针对Android的默认密钥库(即开发人员密钥库)发出此命令时,它很容易在其中提供MD5.因此,我还提出了一个问题,即当我的JRE版本大于10时,Android Studio或Eclipse如何做到这一点?

Also, I have tried and known that when this command is issued inside Android Studio or Eclipse for the Android's default keystore, that is developers keystore, it readily gives MD5 there. So I also had raised the question about how Android Studio or Eclipse is able to do that when my JRE version is > 10?

因此,我正试图找到解决同一问题的方法.

So I am trying to find the solution, other way round, for the same problem.

  1. 以什么方式,在仍然安装v10的同时,我仍然能够使用JRE/JDK v7的功能?通过哪种方式,我可以在Window 7(即我的操作系统)的Java控制面板中指定要使用Java 7.

  1. In what way, I can still be able to use features of JRE/JDK v7, while v10 remained installed? In what way, I can be able to specify in java control panel in Window 7 (that is my OS), that I want to use Java 7.

对于Oracle支持,我很难获得"Support Identifier"信息以获取该版本.所以有人可以指导我如何获得它.

It is difficult for me to get "Support Identifier" information, for the oracle support, to get that version. So someone can guide me how to obtain that as well.

请在站点页面中搜索"Java SE 7, and Java SE 6 updates":

https://www.oracle.com /technetwork/java/javase/downloads/index-jsp-138363.html

请在打开的页面中单击超链接:"My Oracle Support",然后在其后的页面中查找"Support Identifier".

Please look for "Support Identifier" in the page that opens, after you click on the hyperlink : "My Oracle Support" in that paragraph, that follows.

:这是一些使用密钥存储并从keyStore中找出SHA值的Base64的代码:

: Here is some code that uses key-store and finds out the Base64 of SHA value from keyStore:

 try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "com.sample.app", 
                PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
    /*Note: may be instead of converting obtained bytes into Base64, 
I should convert it into hex string.*/
            }
    } catch (NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }

请告诉我是否有答案. MD5的长度至少应为32个字节.

Please let me know if this suggests an answer. MD5 should be at least 32 bytes long.

最好的问候,

您的关注者.

推荐答案

肯定在线程中给出了答案:

Surely the answer is given in the thread:

如何在Android中以编程方式读取SHA和MD5指纹?

在此答案中,@ NateZh使用代码直接获取Digest的"MD5"实例而不是"SHA",并将byteArray []转换为十六进制字符串,并提供了变体:

Here in this answer @NateZh has used code to get "MD5" instance of Digest straight forwardly instead of "SHA", together with converting byteArray[] to HEX String, as well as providing variations:

a.从签名中获取MD5.

a. Getting MD5 from signature.

b.从byteArray []

b. Getting MD5 from byteArray[]

提示:

MessageDigest messageDigest = null;
StringBuffer md5StrBuff = new StringBuffer();
try {
messageDigest = MessageDigest.getInstance("MD5");
//... so on

快乐的编码和探索:-)

Happy Coding and Exploring :-)

最好的问候

这篇关于MD5:Java 7及更高版本中keytool.exe的输出差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆