### Question:
NativeRiJargon2Backend implements Jargon2Backend { byte[] base64decode(String encoded) { int outputLength = encoded.length() / 4 * 3; int mod4 = encoded.length() % 4; if (mod4 != 0) { outputLength += (mod4 - 1); } byte[] output = new byte[outputLength]; char[] buf = new char[4]; int i = 0; int j = 0; while (i < encoded.length() - 3) { encoded.getChars(i, i + 4, buf, 0); output[j++] = (byte) ((decodeMapping(buf[0]) << 2) | (decodeMapping(buf[1]) >>> 4)); output[j++] = (byte) ((decodeMapping(buf[1]) << 4) | (decodeMapping(buf[2]) >>> 2)); output[j++] = (byte) ((decodeMapping(buf[2]) << 6) | (decodeMapping(buf[3]) & 0xFF)); i += 4; } if (i == encoded.length() - 2) { encoded.getChars(i, i + 2, buf, 0); output[j] = (byte) ((decodeMapping(buf[0]) << 2) | (decodeMapping(buf[1]) >>> 4)); } else if (i == encoded.length() - 3) { encoded.getChars(i, i + 3, buf, 0); output[j++] = (byte) ((decodeMapping(buf[0]) << 2) | (decodeMapping(buf[1]) >>> 4)); output[j] = (byte) ((decodeMapping(buf[1]) << 4) | (decodeMapping(buf[2]) >>> 2)); } else if (i != encoded.length()) { throw new Jargon2BackendException("Wrong number of characters in base64 string"); } return output; }  @Override byte[] rawHash(Type type, Version version, int memoryCost, int timeCost, int lanes, int threads, int hashLength, byte[] secret, byte[] ad, byte[] salt, byte[] password, Map<String, Object> options); @Override String encodedHash(Type type, Version version, int memoryCost, int timeCost, int lanes, int threads, int hashLength, byte[] secret, byte[] ad, byte[] salt, byte[] password, Map<String, Object> options); @Override boolean verifyEncoded(String encodedHash, int threads, byte[] secret, byte[] ad, byte[] password, Map<String, Object> options); @Override boolean verifyRaw(Type type, Version version, int memoryCost, int timeCost, int lanes, int threads, byte[] rawHash, byte[] secret, byte[] ad, byte[] salt, byte[] password, Map<String, Object> options);  }### Answer:
@Test(expected = Jargon2BackendException.class) public void base64WrongCharTest() { backend.base64decode("YW55IGNhcm*hbCBwbGVhcw"); }
@Test(expected = Jargon2BackendException.class) public void base64WrongChar2Test() { backend.base64decode("Φούμπαρ"); }
@Test(expected = Jargon2BackendException.class) public void base64WrongNumber1Test() { backend.base64decode("A"); }
@Test(expected = Jargon2BackendException.class) public void base64WrongNumber2Test() { backend.base64decode("AAAAA"); }
@Test(expected = Jargon2BackendException.class) public void base64WrongNumber3Test() { backend.base64decode("AAAAAAAAA"); }