Class Bytes

java.lang.Object
co.cryptoservice.sdk.Bytes

public final class Bytes extends Object
The two binary encodings the API uses, so callers can pass and read byte[] without guessing: lowercase hex for keys, signatures, digests, MACs, shared secrets, KEM ciphertexts and HPKE output; standard base64 with padding for AEAD, secretbox, sealed-box, stream, password-encryption and AES-KW output. Each result record's ...Bytes() accessor applies the encoding its OpenAPI schema names.

These are text encodings only; the SDK performs no cryptography.

  • Method Details

    • hex

      public static String hex(byte[] bytes)
      Encodes bytes as lowercase hex, for request members the API reads as hex.
      Parameters:
      bytes - the bytes
      Returns:
      the hex text
    • fromHex

      public static byte[] fromHex(String hex)
      Decodes hex text (either case).
      Parameters:
      hex - the hex text
      Returns:
      the bytes
      Throws:
      IllegalArgumentException - when the text is not hex of even length
    • base64

      public static String base64(byte[] bytes)
      Encodes bytes as standard base64 with padding.
      Parameters:
      bytes - the bytes
      Returns:
      the base64 text
    • fromBase64

      public static byte[] fromBase64(String base64)
      Decodes standard base64.
      Parameters:
      base64 - the base64 text
      Returns:
      the bytes
      Throws:
      IllegalArgumentException - when the text is not base64