Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help in this piece of Encryption...
#1
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.
Reply
#2
(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.
Reply
#3
Dude,the "encKey" will be pass down when we call this method.
Reply
#4
You need the method xorEnc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)