Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

XOR 2 strings in Java

Name: Anonymous 2009-03-20 3:49

How it should be done?

Name: 10 2009-03-20 12:15

public class XorStrings {
    public static String xor(String a, String b) {
        if (a.length() != b.length())
            throw new IllegalArgumentException("
JEWS");

        char[] as = a.toCharArray();
        char[] bs = b.toCharArray();

        for (int i = 0; i < a.length(); i++)
            as[i] ^= bs[i];

        return new String(as);
    }
}


Next time, get it right.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List