Take the 2-minute tour ×  I'm trying to encrypt a string, part
of it is to XOR the text with IV string. After having some
difficulties I ended up in stackoverflow where a guy gave the
following code:  import sun.misc.BASE64Decoder; import
sun.misc.BASE64Encoder; import java.io.IOException;  public
class StringXORer {  public String encode(String s, String key)
{     return base64Encode(xorWithKey(s.getBytes(),
key.getBytes()));  public String decode(String s, String key) {
return new String(xorWithKey(base64Decode(s), key.getBytes()));
private byte[] xorWithKey(byte[] a, byte[] key) {     byte[] out
= new byte[a.length];         out[i] = (byte) (a[i] ^
key[i%key.length]);     return out;  private byte[]
base64Decode(String s) {     try {         BASE64Decoder d = new
BASE64Decoder();         return d.decodeBuffer(s);  private
String base64Encode(byte[] bytes) {     BASE64Encoder enc = new
BASE64Encoder();     return enc.encode(bytes).replaceAll("\\s",
"");   It seemed to work except for 2 issues: The res