programming-examples/java/Core_Java/Password Encryption class.java

33 lines
989 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
Password Encryption class
/**
Usage: PasswordEncryption pe = new PasswordEncryption();
String pwd = pe.getEncriptedData(string_to_encrypt);
*/
public class PasswordEncryption{
public PasswordEncryption(){}
/**
This Method returns encripted String data
*/
public String getEncriptedData(String str){
str=str.substring(4)+str.substring(2,3)+str.substring(1,4)+str.substring(0,1);
str=""+str.hashCode();
String retString = "";
int a=0;
for(int i=0;i retString = retString + str.valueOf(str.charAt(i));
if(i == 0){
retString=retString+(a+i);
a=a+25;
}
else if(i == 1){
retString=retString+(a-i+7);
}
else if(i == 3){
retString=retString+a+(i*10);
}
}
return retString.trim();
}
}