Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

JNI and Crypt

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I'm really a C++ programmer, just recently made the shift to Java. Now, I've got two problems:
1. How does one call a C++ dll (under windows) from java? I know you use the JNI and define the method as native, but where, what how? anyone got a simple little example?
2. I've written a C++ trapdoor encryption function. Now, if I can figure out the way to use the JNI, I can call the dll from Java, but I'd prefer to use straight java, for portability reasons. Does java have an encryption method/algorithm? Or can anyone suggest a place where I can find source code for robust one-way encryption, in java? I can't write the thing myself (cryptograhpy is not my forte and the C++ code uses calls like memset etc).
I'd apperiaciate any and all suggestions.
Thanks!!
Mari
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using the 1.4 jdk, then the javax.crypto package is included. You probably want to use javax.crypto.Cipher class. It used to be part of a separate download in 1.3 called JCE (Java Cryptography Extension), so if you're using that, you'll have to download it from the sun site.
Also, note that the version included with the JDK 1.4 is "weak" to comply with the U.S.'s illogical laws on exporting cryto technology outside the country. If you need a stronger crypto system, you can get that from Sun as well but they make you fill out a questionaire to verify that you are legally allowed to get it.
For the native method calls, you can check out the tutorial on Sun's site.:
http://java.sun.com/docs/books/tutorial/native1.1/concepts/index.html
In fact, I always recomend everyone first search for info on the Sun site, as it is very comprehensive on all things Java.
[ July 02, 2002: Message edited by: Rob Ross ]
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
If your are a C++ programmer then I think that the following tutorial will be extreamly helpful for you. I think you should read that as a necessary reading.
Enhance your Java application with Java Native Interface (JNI)
Ragards,
Abdullah.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic