Interface Base

All Known Implementing Classes:
LazySodium, LazySodiumJava

public interface Base
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    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)
     
    str(byte[] bs)
    Converts a byte array to a string using a charset.
    str(byte[] bs, 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 Details

    • successful

      boolean successful(int res)
    • res

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

      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

      String str(byte[] bs, 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(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.