The Huawei unlock code calculator works by taking the device's IMEI (International Mobile Equipment Identity) number as input. The IMEI number is a unique 15-digit code assigned to every mobile device. The calculator uses this IMEI number to generate a 16-digit unlock code, which is then entered into the device to unlock it.