Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8551685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:14:57+00:00 2026-06-11T14:14:57+00:00

How can i convert the following Base64 encode binary string into a binary in

  • 0

How can i convert the following Base64 encode binary string into a binary in java. I have seen people doing the same in php using the following code. How to achieve this in java?

In PHP:

$byteArr = "AAAAAEAA";
$maparray = array();
$map = "";
foreach(str_split($byteArr) as $c)
    $maparray [] = sprintf("%08b", ord($c));
$map = implode("", $maparray );

Output is $map -> "000000000000000000000000000000000100000000000000";

But when i try this in java:

String input = "AAAAAEAA";
String mapArray = "";
for(int b=0;b<input.length();b++){
   int asciValueOfChar =(int)toByte.charAt(b);
   String binaryInt = Integer.toBinaryString(asciValueOfChar);
   String paddedBinaryInt = String.format("%8s", binaryInt);
   paddedBinaryInt = paddedBinaryInt.replace(' ', '0');
   System.out.println("ASCII Code::"+asciValueOfChar);
   System.out.println("Binary of Char::"+binaryInt);
   System.out.println("Binary of Padded Char::"+binaryInt);
   mapArray = mapArray + paddedBinaryInt ;
}
System.out.println("Binary Array::"+mapArray);

Output is mapArray -> "0100000101000001010000010100000101000001010001010100000101000001"

The output varies.

How can i achieve the same output?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:14:58+00:00Added an answer on June 11, 2026 at 2:14 pm

    First of all, I don’t believe PHP gives you above mentioned string (000000000000000000000000000000000100000000000000) as an output!

    The code in your question enumerate each character in input string (AAAAAEAA), retrieves ASCII value of each character and post it in output. If you execute PHP code you mentioned, you will give exact the same output, as running JAVA code you mentioned (0100000101000001010000010100000101000001010001010100000101000001).

    For example,

    ord("A") = 65
    

    65 in turn has 01000001 binary representation.

    Second, correct your question to get correct answer. It seems, guys, answered earlier, didn’t understand your question at all.

    Third, if you want to get binary represenation of a given string, use getBytes() method to retrieve bytes representation of entire string. Use or adapt this code snippet to get binary representation of a given bytes-array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I convert Base64 encode data into hex format. I get following data
I have never used Foxpro before. Can you convert the following Foxpro code into
Just wondering how I can convert the following string into a datetime 111222, at
How can I convert the following statement into razor syntax? OnDocumentReady Method accepts Action
How can i convert the following code into JSP. I tried ${} and <%=
How can I convert the following list to a string ? list1= [[1, '1',
How can you convert the following while loop to a for -loop in PHP?
How I can convert the following methods to C# 2.0? private static string ToHexString(byte[]
How can I convert the following Binary value to Bitmap image in ASP.NET C#
How can I convert the following C# hexadecimal into a VB.NET hexadecimal? private const

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.