下载并解压缩
您可以从下面的相应链接下载适用于Windows 32和64位的openssl:
https://code.google.com/archive/p/openssl-for-windows/downloads
64位的OpenSSL 32位的OpenSSL
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | **"C:\Users\keshav.gera\openssl-0.9.8k_X64\bin**\openssl.exe" sha1 -binary | **"C:\Users\keshav.gera\openssl-0.9.8k_X64\bin**\openssl.exe" base64
重要的是 更改此处的路径,以及在系统中安装open ssl
毫无疑问
C:\Users\keshav.gera>keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | "C:\Users\keshav.gera\openssl-0.9.8k_X64\bin\openssl.exe" sha1 -binary | "C:\Users\keshav.gera\openssl-0.9.8k_X64\bin\openssl.exe" base64
输入密钥库密码: android
**ZrRtxw36xWNYL+h3aJdcCeQQxi0=**
================================================== ===========
通过编码手动使用
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
private void PrintHashKey() {
try {
PackageInfo info = getPackageManager().getPackageInfo("**com.keshav.patanjalidemo Your Package Name Here**", 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 (PackageManager.NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}