Skip to content

Instantly share code, notes, and snippets.

@erlangparasu
Last active June 19, 2018 14:38
Show Gist options
  • Select an option

  • Save erlangparasu/edbf520b046015a7513482cbb188c174 to your computer and use it in GitHub Desktop.

Select an option

Save erlangparasu/edbf520b046015a7513482cbb188c174 to your computer and use it in GitHub Desktop.
public static String asciiStringToHexString(String strAscii) {
char[] chars = strAscii.toCharArray();
StringBuilder stringBuilder = new StringBuilder();
for (char aChar : chars) {
String aHex = String.format("%H", aChar);
stringBuilder.append(aHex);
}
String strHex = stringBuilder.toString();
return strHex;
}
// Ref: https://www.boraji.com/how-to-convert-ascii-to-hex-in-java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment