Following is a code that will encrypts the user String :
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.No
For Base64 encryption and decryption this warning clearly says that it does not encourage the use of Sun implementation of Base64Encoder and gives a warning that the implementation may be removed in future releases, what we can do is to switch to other implementation of Base64 encoder. We can use Commons Codec library for Base64 Encoder. Following is an example:
1. Add Commons Codec library in classpath of your project
2. Add import statement for Base64 Class.
import org.apache.commons.codec.binary.Base64;
3. Encrypt your data
String testString = "Hello World";
byte[] encodedBytes = Base64.encodeBase64(testString.getBytes());
// Get encoded string
String encodedString = new String(encodedBytes);
// Get decoded string back
String decodedString = new String(Base64.decodeBase64(encodedBytes));
After using Commons codec library, you should not see above warning again.