byte in Java is 8 bit signed. So you will get negative values.

Change

System.out.println(s[i]);

to

System.out.println(s[i]&0xff);

to get the same values.

Update: I just saw that Java 8 introduced Byte.toUnsignedInt(). This is perhaps more readable:

System.out.println(Byte.toUnsignedInt(s[i]));
Answer from Axel on Stack Overflow
🌐
GitHub
gist.github.com › dangiankit › a3db8f9579328275954d3b4b8cbd2b2d
Base64 Java Encoding to Python Decoding · GitHub
Base64 Java Encoding to Python Decoding · Raw · DecodingValidator.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
Buzzform
buzzform.com › home › base64 encoding and decoding using java, python
Base64 Encoding and Decoding using Java, Python - Buzzform
May 12, 2019 - import base64 message = "Buzz:form.com" encoded_message = base64.b64encode(message) decode_message = base64.b64decode(encoded_message) print("Actual Message: " + message) print("Encode Message: " + encoded_message) print("Decoded Message: " + decode_message)
🌐
Java Guides
javaguides.net › 2020 › 02 › base64-decode-online.html
Base64 Decode Online
August 20, 2023 - ▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube · ▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube · Base64 Decoder is a simple and easy-to-use ...
🌐
Softbaba
base64.softbaba.com › java-base64-decode-online.php
Java Base64 Decode Online
Base64 Decoder/Encoder is a online free tool to turn binary data into text of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.
🌐
Softbaba
base64.softbaba.com › base64-decode-java-online.php
Base64 Decode Java Online
My base64 encoder/decoder process the request in your browser with javascript, "Base64" can refer to a variety of encoding types that take binary data and ... Simple, free and easy to use online tool that decodes base64 to an image. No ads, popups or nonsense, just a base64 to image converter. Load base64 – get · https://onlineimagetools.com/convert-base64-to-image · Php version of perl's MIME::Base64::URLSafe, that provides an url-safe base64 string encoding/decoding (compatible with python base64's urlsafe methods).
🌐
Coderanch
coderanch.com › t › 696645 › java › BASE-Encoding-Key-python-java
BASE64 Encoding with Key (python to java conversion) (Java in General forum at Coderanch)
I just need to create URL safe string base64 encode/decode functions that is the equivalent of the python functions. ... There is no such thing as encoding with a key. You encrypt binary data with a key. Then you map that binary data to a subset of a character set. The latter is done using Base64.Encoder. The former you must write yourself, because substitution ciphers are not part of the standard Java API.
🌐
Base64.Guru
base64.guru › converter › decode
Base64 Decode | Base64 Converter | Base64
The “Base64 Decode Online” is a free decoder for decoding online Base64 to text or binary. In other words, it is a tool that converts Base64 to original data. This online decoder is as smart as it is simple. Its superpower is the ability to automatically detect the encoding standard.
🌐
Coding
coding.tools › base64-decode
Base64 Decode Online Tool - Coding.Tools
Absolutely NOT, this Base64 Decode doing all the formatting work on the client side, all logic are implemented by Javascript. There are 2 major advantages: 1.Your data never transmitted in the Open Internet, so you know it's secure; 2.It's much faster than doing all the work in the server side, because there is no Internet Delay. RFC 3548: https://tools.ietf.org/html/rfc3548.html · Python Implementation of Base64: https://docs.python.org/2/library/base64.html
Find elsewhere
🌐
Qodex
qodex.ai › home › all tools › base64 decoder
Base64 Decode Online, Free Encoder & Decoder
Online Decoders: If you’re in a hurry or don’t want to fuss with code, plenty of free websites let you paste a Base64 string and instantly get the decoded result. While handy for quick checks, these aren’t ideal for handling sensitive data in production environments. Programming Language Libraries: Most popular programming languages, think Python, JavaScript, Java, and C#, include built-in support for Base64 decoding.
🌐
Base64 Decode and Encode
base64decode.net
Base64 Decode and Encode - Online Tool
Python base64.b64decode() Perl decode_base64() VB System.Convert.FromBase64String() C# System.Convert.FromBase64String() Java decode() Golang DecodeString() Ruby Base64.decode64() MySQL from_base64() Dojo dojox.encoding.base64.decode() PostgreSQL decode() Linux base64 decode ·
🌐
Python
docs.python.org › 3 › library › base64.html
base64 — Base16, Base32, Base64, Base85 Data Encodings
Source code: Lib/base64.py This module provides functions for encoding binary data to printable ASCII characters and decoding such encodings back to binary data. This includes the encodings specifi...
🌐
Base64 Decode and Encode
base64decode.net › python-base64-b64decode
Python base64.b64decode() - Base64 Decode
The decoded string is returned. A TypeError is raised if s were incorrectly padded or if there are non-alphabet characters present in the string. <<< import base64 <<< encoded = 'YmFzZTY0IGVuY29kZWQgc3RyaW5n' <<< data = base64.b64decode(encoded) <<< data 'base64 encoded string'
🌐
Base64.Guru
base64.guru › home › developers › java
Java Base64 Decode | Java | Developers | Base64
Hello, That’s right, you should use the same method, both for decoding text and for binary data. Just keep in mind that the decode() method returns a byte array. By the way, you can see a full example here: Convert Base64 to PDF in Java.
🌐
Authgear
authgear.com › post › base64-encode-decode-guide
Base64 Made Easy: How to Encode and Decode Data (Plus Free Online Tool)
February 12, 2026 - Most programming languages offer built-in support for Base64. The examples below demonstrate how to decode encode Base64 in JavaScript, Python, Go, Java, and Bash.
🌐
W3Schools
w3schools.com › python › ref_module_base64.asp
Python base64 Module
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... import base64 s = "Linus".encode() b = base64.b64encode(s) print(b) print(base64.b64decode(b).decode()) Try it Yourself »
🌐
Keploy
keploy.io › home › community › base64 decode: how it works with examples in every language [2026]
Base64 Decode: How It Works with Examples in Every Language
June 28, 2024 - Learn how Base64 decode works and how to decode Base64 strings. Includes encoding explanation, examples, and code in Python, JavaScript, and Java.
🌐
Base64 Encode
base64encode.net
Base64 Encode - Online Tool
Python base64.b64encode() Perl encode_base64() VB System.Convert.ToBase64String() C# System.Convert.ToBase64String() Java encode() Golang EncodeToString() Ruby Base64.encode64() MySQL to_base64() Dojo dojox.encoding.base64.encode() PostgreSQL encode() Linux base64 encode ·