简体   繁体   中英

What Type of Hash is the Test Device ID of AdMob?

What is the Hash of Test Device ID by AdMob? I have the Device Number. But not the Hash and i will Hashing the number.

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.

use md5 for getting hash id here is a procedure

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 "";
}

another way to get the hash id is installing Admob test device id app

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM