Linked Questions
40 questions linked to/from How can I convert a byte array to hexadecimal in Java?
1 vote
1 answer
2k views
converting byte array of decimal value to hexadecimal string in java [duplicate]
i m new to java. i want to convert a byte array of decimal value to hexadecimal string. my input byte array is [0, 0, 0, 0, 0, 0, 1, -28]. i m getting 00000000000001e4 instead of 0000001e4. plz help ...
1 vote
1 answer
1k views
How to convert byte to hexadecimal string in Java [duplicate]
I have a MAC address represented as a byte[] in Java and want it as a hexadecimal string, as they are usually represented. How can I do this with as easy as possible? The byte array has length 6.
831 votes
34 answers
1.1m views
Java: convert a byte array to a hex string?
I have a byte array filled with hex numbers and printing it the easy way is pretty pointless because there are many unprintable elements. What I need is the exact hexcode in the form of: 3a5f771c
462 votes
25 answers
653k views
Convert a string representation of a hex dump to a byte array using Java?
I am looking for a way to convert a long string (from a dump), that represents hex values into a byte array. I couldn't have phrased it better than the person that posted the same question here. But ...
183 votes
13 answers
326k views
Java String to SHA1
I'm trying to make a simple String to SHA1 converter in Java and this is what I've got... public static String toSHA1(byte[] convertme) { MessageDigest md = null; try { md = ...
16 votes
5 answers
41k views
Java Convert 4 bytes to int
i was wondering if the solution for this documented here is still the solution or is there any other way getting an int from 4 bytes? thank you. EDIT: im getting the byte[] from sockets .read EDIT: ...
16 votes
1 answer
24k views
Java 9: Module java.xml.bind is not accessible in Eclipse
I migrating a maven project in Java 8 to a Java 9 project without any build tool in Eclipse OxyGen 1a. So my module-info.java looks like this: But java.xml.bind is not accessible, although its in my ...
5 votes
1 answer
8k views
Leading zeros when computing SHA-256 hash
I am trying to compare the SHA-256 hash values of the same file with Python and Java. However, in some instances, the Python hash value has leading zeros, whereas the Java version does not. For ...
4 votes
2 answers
7k views
SHA256 in PHP & Java
I'm porting some Java code to PHP code. In Java I have a hash SHA256 code as below: public static String hashSHA256(String input) throws NoSuchAlgorithmException { MessageDigest mDigest = ...
3 votes
1 answer
10k views
Insert Java byte[] object into an H2 table and then retrieve it again
I'm trying to insert a Java byte[] into an H2 database table and then retrieve it again, but i am not achieving success. According to this page, the BINARY data type maps directly to a byte[]. So my ...
3 votes
3 answers
2k views
How store values greater than 127 in byte datatype in java
How store values greater than 127 in byte datatype in java. int b = 160; System.out.println((byte)b); It prints -96. Note : I want to write bytes on a BLE device. So can not convert it to short ...
-5 votes
1 answer
12k views
Write byte array to file in java
I want to write byte array to txt file. Firstly I want to see that data in eclipse console and I see that data are true. But when I want to write this data into txt file the problem is manifest itself....
3 votes
1 answer
5k views
How can I receive to socket input as hexadecimal?
I sent a GET message with socket. And I received response message as string. But I want to receive as hexadecimal. But I didn't accomplish. This is my code block as string. Can you help me ? ...
2 votes
1 answer
5k views
Array of Bytes (as hex) conversion to Int issue. (Kotlin/Java)
I'm looking at parsing information from a temp/humidity sensor that was provided with the following instructions; There are 6 bytes. Temperature positive/negative: 0 means positive (+) and 1 ...
2 votes
1 answer
5k views
A simple merkle-tree implementation in java
I am attempting to write a very simple merkle-tree implementation in Java. I am using the values of the txids in block 170 on the bitcoin blockchain for reference, so I can see what the correct ...