Java - Crypt32Util - ClassNotFoundException

Java - Crypt32Util - ClassNotFoundException

我正在尝试解密我有权访问的数据库的值。 密码通过 Windows API 加密。所以我的想法是可以的。让我们尝试以同样的方式解密它!

我正在使用 Java 1.8.0_60 和 JNA-platform.jar...

            while (results.next()) {
            String address = results.getString("value1");
            String username = results.getString("value2");
            String password = new String(Crypt32Util.cryptUnprotectData(results.getBytes("value_which_is_crypted")));
            list.add(new String[] { value1,value2,value_which_is_crypted });

        }

但是,如果我尝试执行我的代码,我将收到 ClassNotFoundException!

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Structure
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access0(Unknown Source)
at java.net.URLClassLoader.run(Unknown Source)
at java.net.URLClassLoader.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:121)
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:103)
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:90)
at recover.Chrome.recover(Chrome.java:35)
at recover.Chrome.main(Chrome.java:49)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Structure
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 17 more

我希望这些信息足够了,因为这显然让我很头疼。 感谢帮助!

编辑:

ok lesson learned.. when using jna include both jna.jar and jna-platform.jar >in your buildpath! Thanks for your help!

您还需要在类路径中包含 jna.jar - com/sun/jna/Structure.class 在该 jar 中。