Browse API 1 documentation
GroveAPI 1preview

grove.crypto.blowfish.encrypt()

Encrypt raw Blowfish blocks for legacy interoperability.

Mango 3.1+View Markdown

Encrypt raw Blowfish blocks for legacy interoperability.

Signature

ts
grove.crypto.blowfish.encrypt(options: {
  mode: 'ecb' | 'cbc'; key: string; data: string; iv?: string
}): Promise<string>

Availability

Packaged runtimes with storage.secure. This helper is for existing legacy protocols; it supplies neither authentication nor a complete FiSH protocol.

Parameters

Parameter Required Description
options.mode Yes Exact lower-case ecb or cbc. Validate before calling: an unrecognized mode is dropped by the native decoder and can leave the Promise pending.
options.key Yes Standard base64 encoding of 1–56 key bytes. Not a Keychain key name or a plaintext passphrase.
options.data Yes Standard base64 encoding of nonempty input bytes; length must be a multiple of 8 and at most 16,384 decoded bytes.
options.iv For cbc Standard base64 encoding of exactly eight IV bytes. Ignored in ecb.

Return value

Resolves to a standard base64 string containing output bytes of the same length as the input.

Behavior and errors

No padding is added or removed. No IV is generated or prepended. Short keys are repeated internally as required by the native Blowfish implementation. Invalid base64, key size, block alignment, body size, CBC IV, missing capability, or crypto failure rejects with Error once the native request has decoded. The extension owns wire encoding, padding, IV handling, and legacy protocol policy.

Example

js
try {
  // Fixed values demonstrate the byte format only; not a production key/IV.
  const result = await grove.crypto.blowfish.encrypt({
    mode: 'ecb', key: 'MDEyMzQ1Njc=', data: 'AAAAAAAAAAA='
  })
  // Decode result with atob when implementing the protocol's wire codec.
} catch {
  console.error('Legacy block operation failed.')
}

See JavaScript objects for the separate browser crypto global.