Hi everyone, i am trying to use some java code to encrypt passwords entering a database on the system i am building, please could someone explain what the code below is doing and if it would be useful for encrypting passwords. Thanks
import java.util.StringTokenizer;
public class Encryption {
public static String encrypt(String password) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i<password.length(); i++) {
char c = password.charAt(i);
int j = c;
sb.append(String.valueOf(j) + " ");
}
return sb.toString().trim();
}
public static String decrypt(String encryptedPassword) {
StringTokenizer st = new StringTokenizer(encryptedPassword, " ");
//A StringTokenizer takes a string as input and breaks it upto tokens, seperated by " "
StringBuffer sb = new StringBuffer();
while (st.hasMoreTokens()) {
int c = Integer.parseInt(st.nextToken());
char chr = (char) c;
sb.append(chr);
}
return sb.toString();
}
}