Please don't mark it as duplicate.
I am using Blowfish Algorithm to Encrypt and Decrypt a Contents in a File. The problem is the output characters of encrypted file having too much of special characters
SPECIAL CHARACTERS (Encrypted text) :- Ž81‡Ç¬ú²±DN¢HÜ4ºÜºT÷.Ê+ŠÀ
after that i had converted the special characters to hex it gives the value as
8E383187C7ACFAB214B113444EA248DC34BADCBA54F7032ECA2B8AC03C6B95C67D2F46F586E4CD86
if i tried to convert this to string i cant get the same encrypted text
Following java code for converting hex to string
package bytearray;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import javax.xml.bind.DatatypeConverter;
public class ByteArray {
public static byte[] toByteArray(String s) {
return DatatypeConverter.parseHexBinary(s);
}
public static void main(String[] args) throws IOException {
String balaji ="8E383187C7ACFAB214B113444EA248DC34BADCBA54F7032ECA2B8AC03C6B95C67D2F46F586E4CD86";
byte[] pri = toByteArray(balaji);
String value = new String(pri);
System.out.println(value);
}
}
Please help us how to convert the hex to string.
Expected Output :- Ž81‡Ç¬ú²±DN¢HÜ4ºÜºT÷.Ê+ŠÀ
Obtained output:- �81�Ǭ���DN�H�4�ܺT�.�+��