JNI wrapper RSA algorithm ideas

JNI (Java Native Interface) is a set of API and standards, it is to achieve Java and other languages (mainly C / C ++) communications. For considerations of computing speed, some of the higher performance requirements of the computing algorithms are often based on C / C ++ language (hardware and more relevant) implementation. If your application needs when JAVA-based programming, which will be some contradictions. In this case, JNI technology, Java developers without knowing the content of the algorithm, convenient to use dynamic library C / C ++ encryption algorithm, cross-language calls. For example the following scenarios: To embedded terminal based on the identity between the complete RSA asymmetric algorithm and the authentication server. Terminal by adding encryption chip, can achieve fast and secure signature verification check based on the work of the RSA algorithm, but server-side encryption module is often not applied, often based on Openssl and other open source libraries to migrate the RSA algorithm, so as to realize the purpose of efficient operations. These libraries are mostly based on the C language source code, this time Java developers can implement signature to encapsulate functions by means of JNI technology.
Package following steps:
1, using the java compiler generates a call RSA encryption and decryption, signature verification check of API header files.
2, based on the generated header files and RSA C source library open source library, generate a static library JNI interface calls for
3 introduced API DLL using Native method in JAVA source code, compile the java program
finally generated file structure shown below :
JNI wrapper RSA algorithm ideas
Note:
1, the Java data types and local data types need to do the appropriate conversion, the corresponding relationship in the following table:
JNI wrapper RSA algorithm ideas
2, if used in the form of the command line directly under the windows, pay attention to the JDK version, the newer version is not supported javah command, but instead of using java -h.

Guess you like

Origin blog.51cto.com/13520299/2480294