• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Store RSA public and private key to mysql database

 
Ranch Hand
Posts: 47
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello friends ,

i want to store the generated keys into mysql database
i want to use RSA as the algorithm
if anyone have sample code for that than please share it

thank you.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, first, we don't just hand out solutions here. Folk will help you figure out how to do it, but you need to do the heavy lifting.

next...where exactly are you stuck? inserting into the database? creating they keys? Installing the JDK?

Your post is really rather vague, so you are going to have a hard time getting specific help. You need to post specific questions. I'd suggest you check our FAQ on HowToAskQuestionsOnJavaRanch (<--that's a link).
 
sanket jani
Ranch Hand
Posts: 47
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is the code which generate two keys


and i am calling this in to the servlet.
and want to store and retrieve from the database
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That code is flawed both in concept and implementation but primarily in concept.

Concept - the concept of public key cryptography is that private and public keys are generated by someone who is the owner. The private key is kept very very secret and secure so that it can only be used by the owner. The public key does not need to be kept secret or secure and should passed to anyone who needs it to use it. This means that you are unlikely to need to generate an RSA key pair in a Servlet since you would have access to every private key generated in response to a client request and your client would not have access unless you sent it to him. Now you could send it over HTTPS to make it secure but your client would then be able to plausibly deny anything signed by that key since it could equally well be have been signed by you.

Implementation - in your encrypt method this line of code

return a string representation of a reference to an array and does not in any way represent the content of the array. Also, the cipher text is binary and an only safely be converted to text using some form of encoding such as Base64 or ASSCII or ASCII85.


Before going any further you need to spend a significant time learning the fundamental concepts since your current code can at best result in a security flawed implementation.






 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic