The ClassNotFoundException for example.com.cryptage.main seems to be the problem. I don't see anything DES related here.
-bri On Sun, Mar 27, 2011 at 4:41 AM, jaafar zbeiba <[email protected] > wrote: > Hello, I have tried DES crypto in Android but, when I launch the > emulator, I get an exception error message. Who can help me? Thanks > [code]import java.security.*; > import javax.crypto.*; > > // > // encrypt and decrypt using the DES private key algorithm > > public class PrivateExample { > > public static void main(String[] args) throws Exception { > // > // check args and get plaintext > if (args.length != 1) { > System.err.println("Usage: java PrivateExample text"); > System.exit(1); > } > > // byte[] plainText = args[0].getBytes("UTF8"); > String ss = "Hello world, haris is here!"; > byte[] plainText = ss.getBytes(); > // > // get a DES private key > System.out.println("\nStart generating DES key"); > KeyGenerator keyGen = KeyGenerator.getInstance("DES"); > keyGen.init(56); > Key key = keyGen.generateKey(); > System.out.println("Finish generating DES key"); > // > // get a DES cipher object and print the provider > Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); > System.out.println("\n" + cipher.getProvider().getInfo()); > // > // encrypt using the key and the plaintext > System.out.println("\nStart encryption"); > cipher.init(Cipher.ENCRYPT_MODE, key); > byte[] cipherText = cipher.doFinal(plainText); > System.out.println("Finish encryption: "); > System.out.println(new String(cipherText, "UTF8")); > > // > // decrypt the ciphertext using the same key > System.out.println("\nStart decryption"); > cipher.init(Cipher.DECRYPT_MODE, key); > byte[] newPlainText = cipher.doFinal(cipherText); > System.out.println("Finish decryption: "); > > System.out.println(new String(newPlainText, "UTF8")); > } > } > [/code] > logcat > [code]03-27 11:28:07.313: ERROR/vold(26): Error opening switch name > path '/sys/class/switch/test2' (No such file or directory) > 03-27 11:28:07.313: ERROR/vold(26): Error bootstrapping switch '/sys/ > class/switch/test2' (No such file or directory) > 03-27 11:28:07.313: ERROR/vold(26): Error opening switch name path '/ > sys/class/switch/test' (No such file or directory) > 03-27 11:28:07.313: ERROR/vold(26): Error bootstrapping switch '/sys/ > class/switch/test' (No such file or directory) > 03-27 11:28:18.263: ERROR/MemoryHeapBase(51): error opening /dev/pmem: > No such file or directory > 03-27 11:28:18.263: ERROR/SurfaceFlinger(51): Couldn't open /sys/power/ > wait_for_fb_sleep or /sys/power/wait_for_fb_wake > 03-27 11:28:18.383: ERROR/libEGL(51): couldn't load <libhgl.so> > library (Cannot load library: load_library[984]: Library 'libhgl.so' > not found) > 03-27 11:28:18.813: ERROR/libEGL(62): couldn't load <libhgl.so> > library (Cannot load library: load_library[984]: Library 'libhgl.so' > not found) > 03-27 11:28:22.663: ERROR/BatteryService(51): Could not open '/sys/ > class/power_supply/usb/online' > 03-27 11:28:22.663: ERROR/BatteryService(51): Could not open '/sys/ > class/power_supply/battery/batt_vol' > 03-27 11:28:22.663: ERROR/BatteryService(51): Could not open '/sys/ > class/power_supply/battery/batt_temp' > 03-27 11:28:23.283: ERROR/EventHub(51): could not get driver version > for /dev/input/mouse0, Not a typewriter > 03-27 11:28:23.283: ERROR/EventHub(51): could not get driver version > for /dev/input/mice, Not a typewriter > 03-27 11:28:23.593: ERROR/System(51): Failure starting core service > 03-27 11:28:23.593: ERROR/System(51): java.lang.SecurityException > 03-27 11:28:23.593: ERROR/System(51): at > android.os.BinderProxy.transact(Native Method) > 03-27 11:28:23.593: ERROR/System(51): at > android.os.ServiceManagerProxy.addService(ServiceManagerNative.java: > 146) > 03-27 11:28:23.593: ERROR/System(51): at > android.os.ServiceManager.addService(ServiceManager.java:72) > 03-27 11:28:23.593: ERROR/System(51): at > com.android.server.ServerThread.run(SystemServer.java:162) > 03-27 11:28:23.604: ERROR/AndroidRuntime(51): Crash logging skipped, > no checkin service > 03-27 11:28:24.833: ERROR/LockPatternKeyguardView(51): Failed to bind > to GLS while checking for account > 03-27 11:28:30.283: ERROR/ActivityThread(111): Failed to find provider > info for com.google.settings > 03-27 11:28:30.293: ERROR/ActivityThread(111): Failed to find provider > info for com.google.settings > 03-27 11:28:31.283: ERROR/ApplicationContext(51): Couldn't create > directory for SharedPreferences file shared_prefs/wallpaper-hints.xml > 03-27 11:28:34.193: ERROR/vold(26): Cannot start volume '/ > sdcard' (volume is not bound) > 03-27 11:28:32.279: ERROR/ActivityThread(109): Failed to find provider > info for android.server.checkin > 03-27 11:28:34.229: ERROR/ActivityThread(109): Failed to find provider > info for android.server.checkin > 03-27 11:28:34.419: ERROR/ActivityThread(109): Failed to find provider > info for android.server.checkin > 03-27 11:28:36.059: ERROR/MediaPlayerService(30): Couldn't open fd for > content://settings/system/notification_sound > 03-27 11:28:36.149: ERROR/MediaPlayer(51): Unable to to create media > player > 03-27 11:28:36.699: ERROR/jdwp(207): Failed sending reply to debugger: > Broken pipe > 03-27 11:28:39.128: ERROR/AndroidRuntime(222): Uncaught handler: > thread main exiting due to uncaught exception > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): > java.lang.RuntimeException: Unable to instantiate activity > ComponentInfo{example.com.cryptage/example.com.cryptage.main}: > java.lang.ClassNotFoundException: example.com.cryptage.main in loader > dalvik.system.PathClassLoader@4376ac98 > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java: > 2324) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: > 2417) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.app.ActivityThread.access$2100(ActivityThread.java:116) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.os.Handler.dispatchMessage(Handler.java:99) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.os.Looper.loop(Looper.java:123) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.app.ActivityThread.main(ActivityThread.java:4203) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > java.lang.reflect.Method.invokeNative(Native Method) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > java.lang.reflect.Method.invoke(Method.java:521) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > com.android.internal.os.ZygoteInit > $MethodAndArgsCaller.run(ZygoteInit.java:791) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > dalvik.system.NativeStart.main(Native Method) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): Caused by: > java.lang.ClassNotFoundException: example.com.cryptage.main in loader > dalvik.system.PathClassLoader@4376ac98 > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > java.lang.ClassLoader.loadClass(ClassLoader.java:573) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > java.lang.ClassLoader.loadClass(ClassLoader.java:532) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.app.Instrumentation.newActivity(Instrumentation.java:1097) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): at > android.app.ActivityThread.performLaunchActivity(ActivityThread.java: > 2316) > 03-27 11:28:39.139: ERROR/AndroidRuntime(222): ... 11 more > 03-27 11:28:39.178: ERROR/dalvikvm(222): Unable to open stack trace > file '/data/anr/traces.txt': Permission denied > 03-27 11:28:40.638: ERROR/ActivityThread(51): Failed to find provider > info for com.google.settings > 03-27 11:28:40.638: ERROR/ActivityThread(51): Failed to find provider > info for com.google.settings > [/code] > > -- > You received this message because you are subscribed to the Google Groups > "Android Security Discussions" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/android-security-discuss?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Android Security Discussions" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/android-security-discuss?hl=en.
