How can I encrypt a String to put it into a Database
I've tried with:
public
static String encrypt(String textoplano) throws IllegalStateException {MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA"); // Instancia de generador SHA-1
}
catch(NoSuchAlgorithmException e) { throw new IllegalStateException(e.getMessage());}
try {md.update(textoplano.getBytes(
"UTF-8"));}
catch(UnsupportedEncodingException e) { throw new IllegalStateException(e.getMessage());}
byte raw[] = md.digest();String hash = (new BASE64Encoder()).encode(raw);
return hash;}
but it requieres to import sun.misc.BASE64Encoder; and sun.misc.CharacterEncoder;, and Visual J# doesn't allow me to import those resources

How can I encrypt a String to put it into a Database?
Mark Levison
If you are using a Microsoft SQL Server 2005, the database has a encryption algorithm built into it.
Lourdes
System.Convert.ToBase64String((ubyte[])(Object)raw) does what you want.