Package burp.mcp.util

Class ByteArrayConverter

java.lang.Object
burp.mcp.util.ByteArrayConverter

public class ByteArrayConverter extends Object
Utility for hex encoding/decoding and byte array conversion. Montoya ByteUtils has no hex methods, so we use java.util.HexFormat (Java 17+).
  • Constructor Details

    • ByteArrayConverter

      public ByteArrayConverter()
  • Method Details

    • toHex

      public static String toHex(byte[] data)
      Convert a byte array to a lowercase hex string.
    • fromHex

      public static byte[] fromHex(String hex)
      Convert a hex string to a byte array.
      Throws:
      IllegalArgumentException - if the string is not valid hex
    • stringToBytes

      public static byte[] stringToBytes(String s)
      Convert a string to bytes using UTF-8 encoding.
    • bytesToString

      public static String bytesToString(byte[] data)
      Convert bytes to a string using UTF-8 decoding. Invalid sequences become U+FFFD replacements (String decoding never throws); use bytesToHex(byte[]) for binary data.
    • bytesToHex

      public static String bytesToHex(byte[] data)
      Encode bytes as a hex string.