Try this java class:
------------------------

public class NETWPIN {
    public static void main(String[] args) {
        String IMSI = "404020506708200";
        byte[] key = getKeyFromIMSI(IMSI);
        String NETWPIN = bytesToHex(key);
        System.out.println("NETWPIN from imsi: " + NETWPIN);
    }
    private static byte[] getKeyFromIMSI(String imsi) {
        imsi = imsi.trim();
        if ((imsi.length() % 2) == 1) {
            imsi = "9" + imsi;
        } else {
            imsi = "1" + imsi;
            imsi = imsi + "F";
        }
        int numDigit = imsi.length();
        String temp = null;
        char c1 = 0;
        char c2 = 0;
        byte b = 0;
        byte[] key = new byte[numDigit / 2]; // always even
        int t = 0;
        for (int i = 0; i < numDigit; i++) {
            c1 = imsi.charAt(i);
            c2 = imsi.charAt(++i);
            temp = "" + c2 + c1;
            try {
                key[t] = (byte) (Integer.parseInt(temp, 16));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            t++;
        }
        return key;
    }
    private static String bytesToHex(byte[] b) {
        StringBuffer buf = new StringBuffer("");
        for (int i = 0; i < b.length; i++) {
            buf.append(byteToHex(b[i]));
        }
        return buf.toString();
    }
    private static String byteToHex(byte b) {
        // Returns hex String representation of byte b
        char hexDigit[] = {
            '0', '1', '2', '3', '4', '5', '6', '7',
            '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
        };
        char[] array = {hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f]};
        return new String(array);
    }
}

Regards
--
Abdulmnem Benaiad
Almontaha CTO
Tripoli-Libya
www.almontaha.ly
about.me <http://about.me/benaiad/bio>



On Wed, Oct 13, 2010 at 6:22 PM, Harmeet Singh
<harmeet.dhing...@gmail.com>wrote:

>  Hi,
>
>
>
> Please help me in understanding how to use NETWPIN with kannel to send OTA
> settings.
>
>
>
> I think i am missing how to calculate HMAC code.
>
>
>
> Will be grateful for any kind of hint .
>
>
>
>
>
> Regards
>
> Harmeet Singh
>
>
>
> *From:* Harmeet Singh [mailto:harmeet.dhing...@gmail.com]
> *Sent:* 12 October 2010 15:29
> *To:* 'Benaiad'
> *Cc:* 'kannel users'
> *Subject:* RE: Regarding IMSI No
>
>
>
> Greetings ,
>
>
>
> Thanks for the reply.
>
>
>
> According to the document i  had calculate the NETWPIN but again same
> message is there i.e Authentication failed .
>
>
>
> My IMSI no is 404020506708200 as per the document i had calculated as 49 40
> 20 50 60 07 28 00 .
>
>
>
> 9 is used to pair.
>
>
>
> It is not working , Please help me in calculating above IMSI no to NETWPIN
> for Kannel.
>
>
>
> Regards
>
> Harmeet Singh
>
>
>
> *From:* Benaiad [mailto:bena...@gmail.com]
> *Sent:* 12 October 2010 11:36
> *To:* Harmeet Singh
> *Cc:* kannel users
> *Subject:* Re: Regarding IMSI No
>
>
>
> Hi,
>
>
>
> This document may help to explain the process of calculating the NETWPIN:
>
>
>
> http://www.nowsms.com/discus/messages/1/OTA_Motorola-3137.pdf
>
>
>  Regards
>
> --
>
> Abdulmnem Benaiad
>
> Almontaha CTO
>
> www.almontaha.ly
>
> Tripoli-Libyan
>
>
>
> On Tue, Oct 12, 2010 at 7:17 AM, Harmeet Singh <harmeet.dhing...@gmail.com>
> wrote:
>
> Greetings,
>
>
>
> I am able to send the OTA Settings Message by using Kannel and UserPin has
> been used , But i want to use Netwpin (Imsi No) .
>
>
>
> I had already verified my IMSI no and it is ok . It has 15 digit .
>
>
>
> After reading and searching i came to know that we should provide Netwpin
> as semi-octets .
>
>
>
> Please help me to know how can i use Netwpin to send the OTA settings.
>
>
>
> Regards
>
> Harmeet Singh
>
>
>
>
>
>
>

Reply via email to