usebruno/bruno · error · Error

Decrypt failed: Invalid algo

Error message

Decrypt failed: Invalid algo

What it means

Thrown by decryptString when the algo segment (str.substring(1, colonIndex)) is not '00' (ELECTRONSAFESTORAGE_ALGO) or '01' (AES256_ALGO). The prefix format is `$<algo>:<ciphertext>`; an unknown algo means the value is from an unsupported scheme or the prefix got corrupted.

Source

Thrown at packages/bruno-electron/src/utils/encryption.js:149

    throw new Error('Decrypt failed: unrecognized string format');
  }
  if (str.length === 0) {
    return '';
  }

  // Find the index of the first colon
  const colonIndex = str.indexOf(':');

  if (colonIndex === -1) {
    throw new Error('Decrypt failed: unrecognized string format');
  }

  // Extract algo and encryptedString based on the colon index
  const algo = str.substring(1, colonIndex);
  const encryptedString = str.substring(colonIndex + 1);

  if ([ELECTRONSAFESTORAGE_ALGO, AES256_ALGO].indexOf(algo) === -1) {
    throw new Error('Decrypt failed: Invalid algo');
  }

  if (algo === ELECTRONSAFESTORAGE_ALGO) {
    if (safeStorage && safeStorage.isEncryptionAvailable()) {
      return safeStorageDecrypt(encryptedString);
    } else {
      return '';
    }
  }

  if (algo === AES256_ALGO) {
    return aes256Decrypt(encryptedString, passkey || null);
  }
  throw new Error('Decrypt failed: Invalid algo');
}

function decryptStringSafe(str) {
  try {

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Validate the prefix with a regex like /^\$(00|01):/ before decrypting.
  2. Upgrade Bruno to a version that supports the algo, or re-create the secret in this version.
  3. Use decryptStringSafe to capture and report the unsupported-algo case without crashing.

Example fix

// before
const algo = str.substring(1, colonIndex);
if ([ELECTRONSAFESTORAGE_ALGO, AES256_ALGO].indexOf(algo) === -1) {
  throw new Error('Decrypt failed: Invalid algo');
}

// after: caller-side guard
const SUPPORTED = /^\$(00|01):/;
if (!SUPPORTED.test(stored)) throw new Error('Unsupported ciphertext prefix');
const plain = decryptString(stored);
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = /^\$(00|01):/;
if (!SUPPORTED.test(stored)) {
  throw new Error('Unsupported ciphertext prefix');
}
return decryptString(stored);

Type guard

function isKnownAlgoCipher(str) {
  return /^\$(00|01):/.test(String(str));
}

Try / catch

try { return decryptString(stored); }
catch (err) {
  if (err.message === 'Decrypt failed: Invalid algo') {
    // value from a newer/unknown scheme; re-enter the secret
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: Value prefixed with an algo code other than '00'/'01' — e.g. a future scheme like '$02:', a hand-edited value, or a value whose leading char was stripped/changed so the algo slice is wrong.

Common situations: Version skew (data written by a newer Bruno using an algo this version doesn't recognize); manual edit of the secrets store; off-by-one corruption dropping the leading '$'.

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/8aeee889bc07e6dd. Report an issue: GitHub.