From 3f9ff6e3b54104d0d5e598f893a8cb8589450e3d Mon Sep 17 00:00:00 2001 From: Abhijay Kumar Date: Thu, 23 May 2019 12:07:30 +0530 Subject: [PATCH] Prevent the byte from getting automatically promoted --- src/main/java/com/crypto/codec/Base64.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/crypto/codec/Base64.java b/src/main/java/com/crypto/codec/Base64.java index 9d1ff91c..f65faf96 100644 --- a/src/main/java/com/crypto/codec/Base64.java +++ b/src/main/java/com/crypto/codec/Base64.java @@ -184,7 +184,7 @@ public class Base64 { decodedBlock[0] = (byte) (decodeAlphabet[block[0]] << 2 | decodeAlphabet[block[1]] >>> 4); decodedBlock[1] = (byte) (decodeAlphabet[block[1]] << 4 | decodeAlphabet[block[2]] >>> 2); - decodedBlock[2] = (byte) (decodeAlphabet[block[2]] << 6 | decodeAlphabet[block[3]]); + decodedBlock[2] = (byte) (decodeAlphabet[block[2]] << 6 | decodeAlphabet[block[3]] & 0xff); return decodedBlock; }