com.facebook.internal.Utility.sha1hash()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中com.facebook.internal.Utility.sha1hash()方法的一些代码示例,展示了Utility.sha1hash()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utility.sha1hash()方法的具体详情如下:
包路径:com.facebook.internal.Utility
类名称:Utility
方法名:sha1hash

Utility.sha1hash介绍

暂无

代码示例

代码示例来源:origin: facebook/facebook-android-sdk

String hashedSignature = Utility.sha1hash(signature.toByteArray());
if (!validAppSignatureHashes.contains(hashedSignature)) {
 return false;

代码示例来源:origin: facebook/facebook-android-sdk

/**
  * Sets up the PackageManager to return what we expect depending on whether app is installed.
  * @param isInstalled true to simulate that app is installed
  */
 private void setupPackageManagerForApp(boolean isInstalled, boolean hasValidSignature)
   throws Exception {
  if (isInstalled) {
   PackageInfo packageInfo = new PackageInfo();
   when(mMockPackageManager.getPackageInfo(PACKAGE_NAME, PackageManager.GET_SIGNATURES))
       .thenReturn(packageInfo);
   Signature signature = mock(Signature.class);
   packageInfo.signatures = new Signature[]{signature};

   if (hasValidSignature) {
    when(Utility.sha1hash(signature.toByteArray())).thenReturn(APP_HASH);
   }
  } else {
   when(mMockPackageManager.getPackageInfo(PACKAGE_NAME, PackageManager.GET_SIGNATURES))
     .thenThrow(new PackageManager.NameNotFoundException());
  }
 }
}

代码示例来源:origin: fr.avianey/facebook-android-api

public static String getHashedDeviceAndAppID(Context context, String applicationId) {
  String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
  if (androidId == null) {
    return null;
  } else {
    return sha1hash(androidId + applicationId);
  }
}

代码示例来源:origin: fr.avianey/facebook-android-api

public boolean validateSignature(Context context, String packageName) {
    String brand = Build.BRAND;
    int applicationFlags = context.getApplicationInfo().flags;
    if (brand.startsWith("generic") && (applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
      // We are debugging on an emulator, don't validate package signature.
      return true;
    }
    PackageInfo packageInfo = null;
    try {
      packageInfo = context.getPackageManager().getPackageInfo(packageName,
          PackageManager.GET_SIGNATURES);
    } catch (PackageManager.NameNotFoundException e) {
      return false;
    }
    for (Signature signature : packageInfo.signatures) {
      String hashedSignature = Utility.sha1hash(signature.toByteArray());
      if (validAppSignatureHashes.contains(hashedSignature)) {
        return true;
      }
    }
    return false;
  }
}

相关文章