Support Forums

Full Version: Help in this piece of Encryption...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
(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.
Dude,the "encKey" will be pass down when we call this method.
You need the method xorEnc.