如何在android studio中获取SHA1指纹证书

时间:2015-09-21 06:59:16

标签: android

SHA1 for Debug

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

发布的SHA1

keytool -list -v -keystore "/home/compe18/Keystore folder/keystore.jks" -alias keystore Alias Name -storepass password -keypass password

注意:storepass和keypass是应用密钥库密码,密钥库=密钥库路径,别名=密钥别名名称(创建密钥库时使用的名称).....

2 个答案:

答案 0 :(得分:1)

通过cmd:

转到java bin目录

C:\ Program Files \ Java \ jdk1.7.0_71 \ bin>

现在在cmd中输入以下命令:

keytool -list -v -keystore c:\users\your_user_name\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

示例:

keytool -list -v -keystore c:\users\James\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

你会得到SHA1 enter image description here

答案 1 :(得分:1)

您还可以运行以下代码:

try {
         PackageInfo info = getPackageManager().getPackageInfo(
                           "yourpackagename", 
                            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));
                  }
            } catch (NameNotFoundException e) {

      } catch (NoSuchAlgorithmException e) {}    
}