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;
    }
}

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Shallow Copy Deep Copy Java example

Database Connection using NODE JS example