Interface Base

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      byte[] bytes​(java.lang.String s)
      Convert a string to directly bytes.
      byte[] removeNulls​(byte[] bs)
      Remove all the null bytes from the end of a byte array.
      <T> T res​(int res, T object)  
      java.lang.String str​(byte[] bs)
      Converts a byte array to a string using a charset.
      java.lang.String str​(byte[] bs, java.nio.charset.Charset charset)
      Convert a byte array to a string with a charset.
      boolean successful​(int res)  
      boolean wrongLen​(byte[] bs, int shouldBeLen)  
      boolean wrongLen​(int byteLength, int shouldBeLen)  
      boolean wrongLen​(int byteLength, long shouldBeLen)  
    • Method Detail

      • successful

        boolean successful​(int res)
      • res

        <T> T res​(int res,
                  T object)
      • str

        java.lang.String str​(byte[] bs)
        Converts a byte array to a string using a charset. This may not be what you want to use if you're storing this string in a database for example. This function will produce null bytes and unexpected carriage returns. Please use Helpers.Lazy.sodiumBin2Hex(byte[]) to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks.
        Parameters:
        bs - The byte array.
        Returns:
        The string.
      • str

        java.lang.String str​(byte[] bs,
                             java.nio.charset.Charset charset)
        Convert a byte array to a string with a charset. This may not be what you want to use if you're storing this string in a database for example. This function will produce null bytes and unexpected carriage returns. Please use Helpers.Lazy.sodiumBin2Hex(byte[]) to convert your byte array to a hexadecimal string that ensures no nulls or carriage breaks.
        Parameters:
        bs - Byte array.
        charset - The charset.
        Returns:
        The byte array as a string.
      • bytes

        byte[] bytes​(java.lang.String s)
        Convert a string to directly bytes.
        Parameters:
        s - The String to convert to a byte array.
        Returns:
        A byte array from s.
      • wrongLen

        boolean wrongLen​(byte[] bs,
                         int shouldBeLen)
      • wrongLen

        boolean wrongLen​(int byteLength,
                         int shouldBeLen)
      • wrongLen

        boolean wrongLen​(int byteLength,
                         long shouldBeLen)
      • removeNulls

        byte[] removeNulls​(byte[] bs)
        Remove all the null bytes from the end of a byte array.
        Parameters:
        bs - A byte array.
        Returns:
        The byte array with no null bytes at the end.