@backblaze-labs/b2-sdk - v0.1.0
    Preparing search index...

    Class EncryptionKey

    Safe wrapper around an SSE-C customer key. Hides the key bytes from JSON.stringify, console.log, and Node's util.inspect. Use EncryptionKey.fromBytes to construct one from a raw 32-byte key; the MD5 digest is computed internally.

    Index

    Properties

    algorithm: "AES256" = 'AES256'

    Encryption algorithm. B2's S3-compatible API only supports AES-256.

    customerKey: string

    Base64-encoded 256-bit customer key. Logged as [redacted SSE-C key] via toJSON / toString.

    customerKeyMd5: string

    Base64-encoded MD5 digest of the customer key. Required by B2 for integrity verification.

    mode: "SSE-C" = ...

    Encryption mode discriminant. Always 'SSE-C' for this class.

    Methods

    • Hides the key bytes from JSON.stringify.

      Returns {
          algorithm: "AES256";
          customerKey: string;
          customerKeyMd5: string;
          mode: "SSE-C";
      }

      A redacted shape: same mode and algorithm, but the key and MD5 replaced with a placeholder string.

      • algorithm: "AES256"

        Encryption algorithm.

      • customerKey: string

        Always the literal redaction placeholder; the real key never leaves the instance.

      • customerKeyMd5: string

        Always the literal redaction placeholder; the real MD5 never leaves the instance.

      • mode: "SSE-C"

        Encryption mode discriminant.

    • Hides the key bytes from default toString().

      Returns string

      A short opaque label indicating this is an SSE-C key.

    • Builds an EncryptionKey from precomputed base64 strings. Use this in environments where MD5 must be computed externally (e.g., browsers).

      Parameters

      • customerKey: string

        Base64-encoded 256-bit encryption key.

      • customerKeyMd5: string

        Base64-encoded MD5 digest of the key.

      Returns EncryptionKey

      A safely-wrapped EncryptionKey ready for upload/download.

    • Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the required base64 MD5 digest internally.

      Parameters

      • rawKey: Uint8Array

        The raw 256-bit key as bytes. Must be exactly 32 bytes.

      Returns Promise<EncryptionKey>

      A safely-wrapped EncryptionKey ready for upload/download.

      If the key is not exactly 32 bytes.