How to Encrypt Decrypt String in java code example
import java.io.PrintStream;
public class EDU_EncryptDecrypt
{
public EDU_EncryptDecrypt()
{
}
public String EDU_getEncryptionDecryptionKey(String seed, String ktype)
{
if(ktype.equals("MSTR_KEY"))
return "89245317";
else
return seed;
}
public String EDU_dataEncryptDecrypt(String istr, String kval)
{
byte bute[] = istr.getBytes();
byte bute1[] = kval.getBytes();
int count = 0;
String cstr = "";
for(int i = 0; i < bute.length; i++)
{
int j = bute[i];
if(i % 8 == 0)
count = 0;
int k = bute1[count];
j ^= k;
cstr = cstr + (byte)j;
count++;
}
return cstr;
}
public class EDU_EncryptDecrypt
{
public EDU_EncryptDecrypt()
{
}
public String EDU_getEncryptionDecryptionKey(String seed, String ktype)
{
if(ktype.equals("MSTR_KEY"))
return "89245317";
else
return seed;
}
public String EDU_dataEncryptDecrypt(String istr, String kval)
{
byte bute[] = istr.getBytes();
byte bute1[] = kval.getBytes();
int count = 0;
String cstr = "";
for(int i = 0; i < bute.length; i++)
{
int j = bute[i];
if(i % 8 == 0)
count = 0;
int k = bute1[count];
j ^= k;
cstr = cstr + (byte)j;
count++;
}
return cstr;
}
}
Comments
Post a Comment