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: Anonymous 2009-03-20 3:51

Same way as in any other language: char by char.

Name: Anonymous 2009-03-20 4:04


    public String xorStrings(String str1, String str2)
    {
        java.concurrent.WorkerSchedulerFactory schedulerFactory = new java.concurrent.WorkerSchedulerFactory();
        java.concurrent.Worker worker = (new java.util.StringXORFactory(java.util.StringXORFactory.DEFAULT_ENCODING)).createWorker(str1);
        worker.setBinaryParameter(str2);
        java.concurrent.DelayedReturn answer = schedulerFactory.schedule(worker);
        String str3;
        try
        {
            str3 = answer.waitForAnswer().stringValue();
        }
        catch(InterruptedException e)
        {
            System.out.println([spoiler]"Fuck you!"[/spoiler]);
        }
        return str3;
    }

Name: Anonymous 2009-03-20 4:04

Fucking piece of shit [code] tag!

Name: Anonymous 2009-03-20 4:59

>>4
There's nothing wrong with the [code] tag. Enjoy you're piece of shit.

Name: Anonymous 2009-03-20 5:11

>>4
Learn toBBCode.

Name: Anonymous 2009-03-20 5:14

>>6
No, YOU learn to BBCode.

Name: Anonymous 2009-03-20 5:56

GREEEEEEN

WEED SHOULD BE LEGAL

Name: Anonymous 2009-03-20 7:02

Contributing to the eventual destruction of /prog/.

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

Name: Anonymous 2009-03-20 10:55

>>9
Why is half of that green?

Name: Anonymous 2009-03-20 11:01

>>10
Son, you have not yet mastered your BBCodes.

Name: Anonymous 2009-03-20 11:07

>>11
It is >>9 who has not yet mastered his BBCodes.

Name: Anonymous 2009-03-20 11:30

>>12
More so than you.

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.

Name: Anonymous 2009-03-20 12:21

>>14
Syntax highlighting is for JEWS. >>9 correctly assumed most of /prog/ uses w3m.

Name: Anonymous 2009-03-20 13:13

I use one-time xor pads for my file encryption needs, so this will be useful to me. Thank you prog.

Name: Anonymous 2009-03-20 13:15

Use B-Tree

Name: Anonymous 2009-03-20 15:05

sub xorstrings { $_[0] ^ $_[1] }

Name: Anonymous 2009-03-20 15:28

>>15
You meant to say that >>9 is not a BBCode Master.

Name: Anonymous 2010-12-17 1:38

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-03 1:47

Name: Anonymous 2011-02-18 13:36

<-- check my doubles

Name: Anonymous 2012-11-25 14:30


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