Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static String calCode(String imei) throws NoSuchAlgorithmException {
- /* Get binary md5 hash of IMEI number */
- MessageDigest messagedigest = MessageDigest.getInstance("MD5");
- messagedigest.update(imei.getBytes());
- byte imeiMD5[] = messagedigest.digest();
- /* Unlock code is 8 digits long */
- byte unlockCode[] = new byte[8];
- /* Calculate each unlock character */
- for(int i = 0; i < 8; i++) {
- int magicalSum = (imeiMD5[i] + imeiMD5[i + 8]) & 0xff; // Get last byte of two md5 byte sum
- unlockCode[i] = (byte) ((magicalSum * 9) / 255 + 48); // We need to add 48 ('0') here to get readable digit in ASCII
- }
- return new String(unlockCode);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement