| | |
Java Encryption and Decryption
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2007
Posts: 24
Reputation:
Solved Threads: 0
Hai,
I am new java developer. Now i am doing one struts application.
In my application, at the User registration time, i need to Encrypt the password field and then i like to store into the database.
After that the same user will be logging, at the moment the database password will decrypt and it will be compare to the User entering password.
If both password's are equal, then only the User will allow the logging.
can anybody know or have any sample code for Encrypt and Decrypt.
If yes, kindly post me my mail id is <email snipped>
I am expecting anyone's reply.
Thanks
Tamilvanan
I am new java developer. Now i am doing one struts application.
In my application, at the User registration time, i need to Encrypt the password field and then i like to store into the database.
After that the same user will be logging, at the moment the database password will decrypt and it will be compare to the User entering password.
If both password's are equal, then only the User will allow the logging.
can anybody know or have any sample code for Encrypt and Decrypt.
If yes, kindly post me my mail id is <email snipped>
I am expecting anyone's reply.
Thanks
Tamilvanan
Last edited by ~s.o.s~; May 26th, 2007 at 2:29 pm. Reason: Keep it on site.
Maybe you should read forum rules regarding homeworks http://www.daniweb.com/techtalkforum...cement9-2.html
and daniweb policies http://www.daniweb.com/techtalkforum...niweb_policies
and daniweb policies http://www.daniweb.com/techtalkforum...niweb_policies
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Apr 2007
Posts: 24
Reputation:
Solved Threads: 0
•
•
•
•
Maybe you should read forum rules regarding homeworks http://www.daniweb.com/techtalkforum...cement9-2.html
and daniweb policies http://www.daniweb.com/techtalkforum...niweb_policies
Hai, Thanks for your suggestion.
This is the good way of improving programming knowledge.
I appreciate this rules.
I have already don e for Encryption, but i don't know how to decrypt the encrypted string.
I am using the following code for encryption.
package com.pmp.actions;
import java.security.MessageDigest;
import java.math.BigInteger.*;
public class Encryption {
public static String Password(String data) {
StringBuffer sb = new StringBuffer();
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-512");
messageDigest.update(data.getBytes("UTF-8"));
byte[] digestBytes = messageDigest.digest();
String hex = null;
for (int i = 0; i < digestBytes.length; i++) {
hex = Integer.toHexString(0xFF & digestBytes[i]);
if (hex.length() < 2)
sb.append("0");
sb.append(hex);
}
String psw = sb.toString();
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
return new String(sb);
}
}
How to decrypt this. Please help me. I am also trying.
Thanks
Tamilvanan
•
•
•
•
In my application, at the User registration time, i need to Encrypt the password field and then i like to store into the database.
After that the same user will be logging, at the moment the database password will decrypt and it will be compare to the User entering password.
Message digests are secure one-way hash functions that take arbitrary-sized data and output a fixed-length hash value.. So you can only encrypt, no reverse process. However there is no need for decryption as MessageDigest class provide public static boolean isEqual(byte[] digesta, byte[] digestb). Compares two digests for equality. Does a simple byte compare. In login process take user entered password, encrypt it and compare with data from database. Problem solved...
Last edited by peter_budo; May 25th, 2007 at 6:54 am.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
•
•
any one plz give source code in java for
encrypted and decrypted password
secondly, the answer is no. maybe we can, but we won't.
you wouldn't be learning anything. just read the answers earlier given in this thread, or go ask Google, you might be surprised what difference a bit of effort can make, but do not expect us to:
a. do your homework
b. do your job
without any effort from your side.
![]() |
Similar Threads
- encryption (Java)
- Java Encryption error (Java)
- Java Encryption (Elections System) (Java)
Other Threads in the Java Forum
- Previous Thread: radio button for multiple choice quiz
- Next Thread: How Do I read in a file as text to a buffer?
| Thread Tools | Search this Thread |
actuate android api applet application applications array arrays automation balls bank binary bluetooth business chat class classes clear client code codesnippet collections component database db development dice dragging draw ebook eclipse error event exception formatingtextintooltipjava fractal game givemetehcodez graphics gui hql html ide image infinite input integer invokingapacheantprogrammatically j2me java javaprojects jni jpanel julia linux list loop looping map method methods mobile mysql netbeans newbie numbers openjavafx oracle parameter php print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting sql sqlserver state storm string sun superclass swing swt text-file threads time tree windows






