AdMob 的测试设备 ID 哈希是什么?我有设备编号。但不是散列,我会散列这个数字。
2 回答
It uses an md5 hash, but it may also have a SALT.
The best way to get the hashed device ID is to check the logcat output when you make an Ad Request on a device. You'll get a message to the effect of:
To get test ads on this device, call adRequest.addTestDevice("0123456789ABCDEF");
That string is your hashed device ID that you can add to your app.
It is NOT RECOMMENDED to try to craft this hashed device ID yourself. If you get the device's ID and hash it to get test ads, but forget to remove that code when you release your app, all of your users will get test ads and you'll make no money. The current mechanism is intended to try and prevent you from making this mistake.
使用 md5 获取哈希 id 这是一个过程
public static final String md5(final String s) {
try {
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest
.getInstance("MD5");
digest.update(s.getBytes());
byte messageDigest[] = digest.digest();
// Create Hex String
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < messageDigest.length; i++) {
String h = Integer.toHexString(0xFF & messageDigest[i]);
while (h.length() < 2)
h = "0" + h;
hexString.append(h);
}
return hexString.toString();
} catch (NoSuchAlgorithmException e) {
Logger.logStackTrace(TAG,e);
}
return "";
}
获取哈希 id 的另一种方法是安装 Admob 测试设备 id应用程序