Support Forums
Help in this piece of Encryption... - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Java Programming (https://www.supportforums.net/forumdisplay.php?fid=22)
+---- Thread: Help in this piece of Encryption... (/showthread.php?tid=2293)



Help in this piece of Encryption... - ethical_john - 10-29-2009

First time I come across Cryptography using JAVA.

This is a basic XOR Encryption I get from the Internet.

Code:
public String xorEncStr(String encKey, String toEnc)
{
        int t=0;
        int encKeyI=0;

        while(t < encKey.length())
        {
            encKeyI+=encKey.charAt(t);
            t+=1;
        }
        return xorEnc(encKeyI,toEnc);
}

I write the full code and use the method,it always give me an error regarding "return xorEnc(encKeyI,toEnc)".

After looking again at this return type function,find out that "xorEnc" is not declare.

Anyone know how to modified this code?

Thanks.


RE: Help in this piece of Encryption... - dongblues - 10-29-2009

(10-29-2009, 03:31 AM)ethical_john Wrote: First time I come across Cryptography using JAVA.

This is a basic XOR Encryption I get from the Internet.

Code:
public String xorEncStr(String encKey, String toEnc)
{
        int t=0;
        int encKeyI=0;

        while(t < encKey.length())
        {
            encKeyI+=encKey.charAt(t);
            t+=1;
        }
        return xorEnc(encKeyI,toEnc);
}

I write the full code and use the method,it always give me an error regarding "return xorEnc(encKeyI,toEnc)".

After looking again at this return type function,find out that "xorEnc" is not declare.

Anyone know how to modified this code?

Thanks.

Look at your while loop.. It says: while t is less than encKey.length.. But where is encKey? It is 0.. In other words the code will not loop back since t = 0 = encKey.


RE: Help in this piece of Encryption... - ethical_john - 10-29-2009

Dude,the "encKey" will be pass down when we call this method.


RE: Help in this piece of Encryption... - Ben - 10-29-2009

You need the method xorEnc.