Friday, November 29, 2013

Message - Up

import java.*;
 
import java.security.MessageDigest;
 
public class pw_test {
        public static void main(String[] args) {
                // Original: String imei = System.getProperty("com.nokia.mid.imei");
                String imei = "580179140553553"; // your IMEI
               
        StringBuffer buffer = new StringBuffer(imei);
        if(buffer.length() == 0)
        {
            System.exit(0);
        }
        buffer = buffer.reverse();
        S40MD5Digest digest = new S40MD5Digest();
        digest.reset();
        try
        {
            digest.update(buffer.toString().getBytes("UTF-8"));
        }
                catch(Exception e)
        {
            e.printStackTrace();
        }
        byte bytes[] = digest.digest();
        int bytesLength = bytes.length;
        buffer = new StringBuffer();
        for(int i = 0; i < bytesLength; i++)
        {
            int unsignedByte = bytes[i] + 128;
            buffer.append(Integer.toString(unsignedByte, 16));
        }
 
        System.out.println(buffer.toString());
    }
}
 
class S40MD5Digest
//    implements com.whatsapp.api.util.MessageDigest
{
 
    public S40MD5Digest()
    {
        try
        {
            _md5 = MessageDigest.getInstance("md5");
        }
        catch(Exception x) { }
    }
 
    public void reset()
    {
        _md5.reset();
    }
 
    public void update(byte bytes[])
    {
        _md5.update(bytes, 0, bytes.length);
    }
 
    public byte[] digest()
    {
        byte arr[] = new byte[128];
        int res;
        try
        {
            res = _md5.digest(arr, 0, 128);
        }
        catch(Exception x)
        {
            return null;
        }
        byte resArr[] = new byte[res];
        System.arraycopy(arr, 0, resArr, 0, res);
        return resArr;
    }
 
    MessageDigest _md5;
}

No comments:

Post a Comment