Home / Function/ encryptString() — astro Function Reference

encryptString() — astro Function Reference

Architecture documentation for the encryptString() function in encryption.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  1e3d5974_da4c_c198_a44a_e69a18e74456["encryptString()"]
  94fbb11e_4aa9_9dfd_28d5_cc0eb8749e6c["encryption.ts"]
  1e3d5974_da4c_c198_a44a_e69a18e74456 -->|defined in| 94fbb11e_4aa9_9dfd_28d5_cc0eb8749e6c
  style 1e3d5974_da4c_c198_a44a_e69a18e74456 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/encryption.ts lines 85–98

export async function encryptString(key: CryptoKey, raw: string) {
	const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH / 2));
	const data = encoder.encode(raw);
	const buffer = await crypto.subtle.encrypt(
		{
			name: ALGORITHM,
			iv,
		},
		key,
		data,
	);
	// iv is 12, hex brings it to 24
	return encodeHexUpperCase(iv) + encodeBase64(new Uint8Array(buffer));
}

Domain

Subdomains

Frequently Asked Questions

What does encryptString() do?
encryptString() is a function in the astro codebase, defined in packages/astro/src/core/encryption.ts.
Where is encryptString() defined?
encryptString() is defined in packages/astro/src/core/encryption.ts at line 85.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free