Encryption password by java MD5 and UTF-8
Hello, I wanna help from any one. I need java encryption password what will be make by MD5 and UTF-8. I wrote some code when i run this program here show some error. Please check and give me full instruction because i m totally new on java programming.
Code java:
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import sun.misc.BASE64Encoder;
public final class MyPasswordEncrypt {
public static synchronized String encrypt(String plaintext,
String algorithm, String encoding) throws Exception {
MessageDigest msgDigest = null;
String hashValue = null;
try {
msgDigest = MessageDigest.getInstance(algorithm);
msgDigest.update(plaintext.getBytes(encoding));
byte rawByte[] = msgDigest.digest();
hashValue = (new BASE64Encoder()).encode(rawByte);
} catch (NoSuchAlgorithmException e) {
System.out.println("No Such Algorithm Exists");
} catch (UnsupportedEncodingException e) {
System.out.println("The Encoding Is Not Supported");
}
return hashValue;
}
public static void main(String args[]) throws Exception {
String plainPassword = "SecretPassword";
System.out.println("PlainText\tAlgo\tEncoding\tEncrypted Password");
System.out.println(plainPassword + "\tSHA\tUTF-8\t"
+ encrypt("MySecretPassword", "SHA", "UTF-8"));
System.out.println(plainPassword + "\tSHA-1\tUTF-16\t"
+ encrypt("MySecretPassword", "SHA-1", "UTF-16"));
System.out.println(plainPassword + "\tMD5\tUTF-8\t"
+ encrypt("MySecretPassword", "MD5", "UTF-8"));
System.out.println(plainPassword + "\tMD5\tUTF-16\t"
+ encrypt("MySecretPassword", "MD5", "UTF-16"));
}
}
Error:
Main.java:7: class MyPasswordEncrypt is public, should be declared in a file named MyPasswordEncrypt.java
public final class MyPasswordEncrypt {
^
Main.java:5: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
import sun.misc.BASE64Encoder;
^
Main.java:16: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
hashValue = (new BASE64Encoder()).encode(rawByte);
Re: Encryption password by java MD5 and UTF-8
Please post the full text of the error message.
Also please Edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Re: Encryption password by java MD5 and UTF-8
Please give me below 5 code encryption result
1. 355735004104438
2. 355735001013871
3. 355735004103463
4. 355735004081859
5. 355735003961712
and post for me correct code and run instruction
Re: Encryption password by java MD5 and UTF-8
Please explain what your problem is. Post your code and ask any questions you may have about it.
Re: Encryption password by java MD5 and UTF-8
Quote:
Originally Posted by
jahirul019
Please give me below 5 code encryption result
1. 355735004104438
2. 355735001013871
3. 355735004103463
4. 355735004081859
5. 355735003961712
and post for me correct code and run instruction
Below warnings show when i run this code
====================================
MyPasswordEncryption.java:6: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in future release
import sun.misc.BASE64Encoder;
MyPasswordEncrypt.java:17: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
hashValue = <new BASE64Encoder<>>.encode<rawByte>;
2 warnings
Re: Encryption password by java MD5 and UTF-8
Below warnings show when i run this code. please tell me with example, how can i solve this error?
MyPasswordEncryption.java:6: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in future release
import sun.misc.BASE64Encoder;
MyPasswordEncrypt.java:17: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
hashValue = <new BASE64Encoder<>>.encode<rawByte>;
2 warnings
Re: Encryption password by java MD5 and UTF-8
If you want to remove the warning, find another class to use.
Re: Encryption password by java MD5 and UTF-8
Quote:
Originally Posted by
Norm
If you want to remove the warning, find another class to use.
How can i do it? Please write an example because I am totally new on java
Re: Encryption password by java MD5 and UTF-8
Re: Encryption password by java MD5 and UTF-8
hello, i m tried to use another class please help me, how can i solve java warning?
Re: Encryption password by java MD5 and UTF-8
Hello, I'm really tired to solve two warning. Below warnings show when i run above code. please give me some example, how can i solve this warning?
MyPasswordEncryption.java:6: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in future release
import sun.misc.BASE64Encoder;
MyPasswordEncrypt.java:17: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release
hashValue = <new BASE64Encoder<>>.encode<rawByte>;
2 warnings
Thanks
Re: Encryption password by java MD5 and UTF-8
Quote:
how can i solve java warning?
Find another class to do the Base64 encoding.
Re: Encryption password by java MD5 and UTF-8
Thanks for your reply, Actually i'm a new student on java class. Please explain me about Base64.
how? Which one?
Re: Encryption password by java MD5 and UTF-8
Please help me with correct code. I did use another class but same problem have been still. I want to get some code without warning and errors.
Thanks
Re: Encryption password by java MD5 and UTF-8
Try using a search for base64 to find out about it.
Perhaps you can find a free class that will do Base64 coding.