Package co.cryptoservice.sdk
Class Bytes
java.lang.Object
co.cryptoservice.sdk.Bytes
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 Summary
Modifier and TypeMethodDescriptionstatic Stringbase64(byte[] bytes) Encodes bytes as standard base64 with padding.static byte[]fromBase64(String base64) Decodes standard base64.static byte[]Decodes hex text (either case).static Stringhex(byte[] bytes) Encodes bytes as lowercase hex, for request members the API reads as hex.
-
Method Details
-
hex
Encodes bytes as lowercase hex, for request members the API reads as hex.- Parameters:
bytes- the bytes- Returns:
- the hex text
-
fromHex
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
Encodes bytes as standard base64 with padding.- Parameters:
bytes- the bytes- Returns:
- the base64 text
-
fromBase64
Decodes standard base64.- Parameters:
base64- the base64 text- Returns:
- the bytes
- Throws:
IllegalArgumentException- when the text is not base64
-