Class ByteArrayConverter

java.lang.Object
de.das.encrypter.tools.ByteArrayConverter

public class ByteArrayConverter extends Object
This class provides a converter to build string from byte arrays and vice versa, where the byte values greater than "0x7F" will be replaced by the values where the MSB of the byte is set to "0" and the MSB itself is placed as a bit into an appended table.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    An identifier to indicate that a string represents a byte array.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byteArrayToString(byte[] data)
    Converts the given byte array into a string consisting of an identifier, a four-byte string representing the number of pure binary data plus four-byte CRC value, the reduced binary data plus CRC value and a table with the removed MSB bits.
    byte[]
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • IDENTIFIER

      public static final String IDENTIFIER
      An identifier to indicate that a string represents a byte array.
      See Also:
  • Constructor Details

    • ByteArrayConverter

      public ByteArrayConverter()
  • Method Details

    • byteArrayToString

      public String byteArrayToString(byte[] data) throws Exception
      Converts the given byte array into a string consisting of an identifier, a four-byte string representing the number of pure binary data plus four-byte CRC value, the reduced binary data plus CRC value and a table with the removed MSB bits.
      Parameters:
      data - the given binary data.
      Returns:
      the converted string.
      Throws:
      Exception - in case of any error.
    • stringToByteArray

      public byte[] stringToByteArray(String str) throws Exception
      Throws:
      Exception