From f14990eaebd9c202eb3fa50c568172fccad5e6b9 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sun, 26 Nov 2017 20:18:39 +0300 Subject: [PATCH] Fix bug in base64 encoder --- .../src/main/java/org/teavm/classlib/impl/Base64Impl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/impl/Base64Impl.java b/classlib/src/main/java/org/teavm/classlib/impl/Base64Impl.java index 32bb7dc2e..c4d480b52 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/Base64Impl.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/Base64Impl.java @@ -118,9 +118,9 @@ public final class Base64Impl { int j; for (j = 0; j < triples;) { output[i++] = encode((byte) (data[j] >>> 2)); - output[i++] = encode((byte) ((data[j] << 4) | (data[j + 1] >>> 4))); + output[i++] = encode((byte) ((data[j] << 4) | ((data[j + 1] & 0xFF) >>> 4))); ++j; - output[i++] = encode((byte) ((data[j] << 2) | (data[j + 1] >>> 6))); + output[i++] = encode((byte) ((data[j] << 2) | ((data[j + 1] & 0xFF) >>> 6))); ++j; output[i++] = encode(data[j]); ++j;