views:

5

answers:

0

package md5;

import java.io.UnsupportedEncodingException; import java.security.; import javax.bluetooth.BluetoothStateException; import javax.bluetooth.LocalDevice; import javax.microedition.lcdui.; import javax.microedition.midlet.; import java.math.;

public class BluetoothMD5Hash extends MIDlet{ private Form form; private Display display;

public BluetoothMD5Hash(){ super(); }

public void startApp(){ try { form = new Form("Hello World"); String msg = "Hello India"; String address = LocalDevice.getLocalDevice().getBluetoothAddress(); String name = LocalDevice.getLocalDevice().getFriendlyName(); // AlertType.CONFIRMATION.hashCode(); form.append(msg); form.append(address); try { String finalMD5 = MungPass(address); } catch (NoSuchAlgorithmException ex) { ex.printStackTrace(); } display = Display.getDisplay(this); display.setCurrent(form); } catch (BluetoothStateException ex) { ex.printStackTrace(); }

}

public static String MungPass(String address) throws NoSuchAlgorithmException, UnsupportedEncodingException { /MessageDigest m = MessageDigest.getInstance("MD5"); byte[] data = pass.getBytes(); m.update(data,0,data.length); String i = new BigInteger(1,m.digest()).toString(16); //return String.format("%1$032X", i); return i;/ //String aString = "teststring"; MessageDigest m = MessageDigest.getInstance("MD5"); m.reset(); m.update(address.getBytes()); byte[] digest = m.digest(); BigInteger bigInt = new BigInteger(1,digest); String hashtext = bigInt.toString(16); while(hashtext.length() < 32 ){ hashtext = "0"+hashtext; } return hashtext; }

public void pauseApp(){}

public void destroyApp(boolean unconditional){ notifyDestroyed(); } }

here is the error which i am facing http://pastebin.com/UNyBQcQJ