只需要能跑Android即可拿到hash Key 不需要讓windows再額外安裝openssl
PackageInfo info;
try
{
info = getPackageManager().getPackageInfo("com.unood.siangtienhu", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures)
{
MessageDigest md;
md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String KeyResult = new String(Base64.encode(md.digest(), 0));//String something = new String(Base64.encodeBytes(md.digest()));
Log.e("hash key", KeyResult);
Toast.makeText(this, "My FB Key is \n" + KeyResult, Toast.LENGTH_LONG).show();
}
}
catch (PackageManager.NameNotFoundException e1)
{
Log.e("name not found", e1.toString());
}
catch (NoSuchAlgorithmException e)
{
Log.e("no such an algorithm", e.toString());
}
catch (Exception e) {Log.e("exception", e.toString());}
沒有留言 :
張貼留言