Under The Hood
frontend bun Bun 1.x (Node.js compatibility)

Native C++ Reimplementation of node:crypto, node:buffer, and node:fs

Last updated
Prerequisites:
Node.js core modules (`node:crypto`, `node:buffer`, `node:fs`)
  • bun
  • node-compat
  • crypto
  • buffer
  • fs
  • boringssl
  • zig

Read at your depth

The practical view

Bun provides a built-in compatibility layer for Node.js core modules (`node:fs`, `node:crypto`, `node:buffer`, `node:path`, `node:http`, `node:events`, `node:child_process`). You can import them directly (`import crypto from 'node:crypto'`) or run existing npm packages (like Express, Prisma, Next.js, Lodash) with near 100% compatibility.

The same idea in other frameworks

node equivalent
Original Node.js C++ and JS core module implementations.

Legacy vs modern

Node.js Core Module Compatibility

Existing Node.js code runs unmodified in Bun, utilizing fast native BoringSSL crypto and SIMD buffers.

before → after
Standard Node.js Code
const crypto = require('node:crypto'); const hash = crypto.createHash('sha256').update(data).digest('hex');
Same Code Running in Bun (BoringSSL)
import crypto from 'node:crypto'; // ✅ NEW: Executes 2-3x faster via native BoringSSL

Interview gotchas

Context

Interviewers test your knowledge of underlying native dependencies in modern runtimes.

The mechanical answer

Node.js uses **OpenSSL**. Bun uses **BoringSSL** (Google's lightweight, high-performance fork of OpenSSL used in Chromium and Android). BoringSSL reduces binary footprint and contains optimized assembly for modern x86-64 and ARM64 cryptographic operations.

Trap

Some legacy, deprecated cryptographic algorithms (like outdated SSLv3 ciphers or obscure DES modes) are intentionally removed in BoringSSL and therefore unsupported in Bun.

Under The Hood — a multi-depth technical interview hub.

Third-party licenses Press ⌘ K to search.