UDID

From The Apple Wiki

A UDID (Unique Device Identifier) is a calculated string that is used to identify a device for the purposes of app installation, registration, and MDM enrollment.

Calculation

There are three different formats of UDID, depending on the device.

While it is useful to know how the UDID is calculated, it is not recommended for developers to manually calculate it using these instructions. Should you have a need to retrieve the UDID in your code, query the UniqueDeviceID key using libMobileGestalt.

September 2018-present

With the release of Apple Watch Series 4, iPhone XR, iPhone XS and iPhone XS Max, the UDID format changed. All devices released after these use the new format:

  1. 8 characters of ChipID padded with zeros on the left, without leading zeros. e.g. 8020 for iPhone XS.
  2. A hyphen, followed by 16 characters of ECID in hexadecimal padded with zeros on left

The general format will be:

[0padding]CHIP-[0padding]ECID

Example:

00008020-008D4548007B4F26

2007-August 2018

For devices released before September 2018, (Apple TV 4K and earlier, Apple Watch Series 3 and earlier, iPad (6th generation) and earlier, iPad mini 4 and earlier, iPhone X and earlier, and iPod touch (6th generation) and earlier), the method to calculate is the following:

  1. Get the 11- or 12-character long serial number (in uppercase)
    • Verizon iPhone 4 and newer: Get the ECID in decimal, with no leading zeroes
    • Earlier devices: Get the IMEI number (without spaces; empty string for iPod touch and Wi-Fi model iPads)
  2. Get the Wi-Fi MAC address (letters in lower case, including colons)
  3. Get the Bluetooth MAC address (letters in lower case, including colons)
  4. Calculate a SHA1 hash of these.

The effective formula for this is below:

On the Verizon iPhone 4 up to iPhone X (inclusive):

UDID = SHA1(serial + ECID + wifiMac + bluetoothMac)

Prior devices:

UDID = SHA1(serial + IMEI + wifiMac + bluetoothMac)

Example:

9f9bb1b742882152fb1746aab7db415cea979232

Changing UDID

Example of Wi-Fi MAC address being spoofed on an iPod touch (4th generation)

On iOS 8 and lower, this form of UDID can be changed by running the command below, followed by a DFU restore. If the DFU restore is not performed, many applications will break, including iTunes. It is very important to first write down the original MAC address and keep that information in a safe place so that you can revert this change if necessary.

It is also very important to not change this to an invalid MAC address. If you change your device's MAC address to something invalid, your internet won't work again until you fix the MAC address (using MobileTerminal or similar). This persists even if you restore - so you can make this hard to fix if you restore and there's no jailbreak available, if the available jailbreaks don't include afc2 and other workarounds aren't working.

Note that changing your UDID can have weird side effects in general, including that you'll have to log in again to everything, including Apple apps.

If you're still willing to risk this, this is the command:

nvram wifiaddr=ma:ca:dd:re:as

Mac

Mac devices use a completely random universally unique identifier (UUID or GUID) in place of what can be considered a UDID. UUIDs are expressed as a 32 hexadecimal character-long string, divided into 5 sections using a hyphen.

Example:

0D990E91-F2D3-430D-8405-A054CEF983CF

Beginning with the M1 series, Mac devices have two "UDIDs": the CHIP and ECID-based format discussed above, named the "provisioning UDID", and the UUID, named the "hardware UUID".