{"_id":"@bun-win32/ncrypt","_rev":"3-39a07a45c4c780c01ed262bb896e9c86","name":"@bun-win32/ncrypt","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/ncrypt","version":"1.0.0","keywords":["bun","ffi","win32","windows","ncrypt","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/ncrypt@1.0.0","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"47e62982f6d2dfdc505e15bd703c7adefa321a2b","tarball":"https://registry.npmjs.org/@bun-win32/ncrypt/-/ncrypt-1.0.0.tgz","fileCount":6,"integrity":"sha512-Vda83qC8iuHsuQ5bN0lNMw9y18pkhvjQAewotBWsp9yNt0TaafT8kXm0lIK0v3zjSlXXFVedQsCnFLtSDIX0wA==","signatures":[{"sig":"MEQCIDKGQSt3TOxG09lV754zo7ejR4WprooXcZtBkupffLSWAiA8QB+gnV3yP6pREpDmlovTm/DmckLfySX7HJ6eXrIR6A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36949},"main":"./index.ts","type":"module","module":"index.ts","shasum":"47e62982f6d2dfdc505e15bd703c7adefa321a2b","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:provider-audit":"bun ./example/provider-audit.ts","example:rsa-sign-verify":"bun ./example/rsa-sign-verify.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-Vda83qC8iuHsuQ5bN0lNMw9y18pkhvjQAewotBWsp9yNt0TaafT8kXm0lIK0v3zjSlXXFVedQsCnFLtSDIX0wA==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/ncrypt"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 NCRYPT bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/ncrypt_1.0.0_1778847649924_0.402358829358036","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/ncrypt","version":"2.0.0","keywords":["bun","ffi","win32","windows","ncrypt","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/ncrypt@2.0.0","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"65898a3e621b9411402a1c979cb832a66b31ca80","tarball":"https://registry.npmjs.org/@bun-win32/ncrypt/-/ncrypt-2.0.0.tgz","fileCount":6,"integrity":"sha512-gUJbTcZHvWdlMoNH2UUB9Y+xo2wy3bXi4SKIC43s/ZJ+oXkUixcCna8mtB5TyDIE9ssBVatYX8kQ1zb8OlvGEg==","signatures":[{"sig":"MEUCIFOGUDSP7pvCbmSb1qN6z0PLoypnIO03wVzGtrS6ey5BAiEA5m9cQJByLfCp+IS8A+kC4QU9cHXCMccqZbaLMCkNYeo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38739},"main":"./index.ts","type":"module","module":"index.ts","shasum":"65898a3e621b9411402a1c979cb832a66b31ca80","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:provider-audit":"bun ./example/provider-audit.ts","example:rsa-sign-verify":"bun ./example/rsa-sign-verify.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-gUJbTcZHvWdlMoNH2UUB9Y+xo2wy3bXi4SKIC43s/ZJ+oXkUixcCna8mtB5TyDIE9ssBVatYX8kQ1zb8OlvGEg==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/ncrypt"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 NCRYPT bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"26.3.0","dependencies":{"@bun-win32/core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/ncrypt_2.0.0_1782435477270_0.7986375117712694","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"author":"Stev Peifer <stev.p@outlook.com>","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dependencies":{"@bun-win32/core":"2.0.1"},"description":"Zero-dependency, zero-overhead Win32 NCRYPT bindings for Bun (FFI) on Windows.","devDependencies":{"@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/ncrypt","peerDependencies":{"typescript":"^5"},"private":false,"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/ncrypt"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","ncrypt","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:provider-audit":"bun ./example/provider-audit.ts","example:rsa-sign-verify":"bun ./example/rsa-sign-verify.ts"},"_id":"@bun-win32/ncrypt@2.0.1","_integrity":"sha512-R03caTmyGGTCek0V627PY5i8P+2+GDSESphhPrSxbIQth0TdIZ14pl8tW+jf+z8txMAav6K0AMJRim9FRyV8EQ==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"7bb0b18b0c1fdaf23f5e0bb84655bbeae77c27b9","dist":{"integrity":"sha512-R03caTmyGGTCek0V627PY5i8P+2+GDSESphhPrSxbIQth0TdIZ14pl8tW+jf+z8txMAav6K0AMJRim9FRyV8EQ==","shasum":"7bb0b18b0c1fdaf23f5e0bb84655bbeae77c27b9","tarball":"https://registry.npmjs.org/@bun-win32/ncrypt/-/ncrypt-2.0.1.tgz","fileCount":6,"unpackedSize":38739,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDm3OUr4a2w1xaapVVtoNpTiHN+I6i2vABKA6dyNqqeFAIhAL7ygHOUci7XYE1Do2+OGHZ3BymMGEU1HoiEgkcdrZRT"}]},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"directories":{},"maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ncrypt_2.0.1_1782438136047_0.6648008109248613"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-15T12:20:49.677Z","modified":"2026-06-26T01:42:16.411Z","1.0.0":"2026-05-15T12:20:50.175Z","2.0.0":"2026-06-26T00:57:57.405Z","2.0.1":"2026-06-26T01:42:16.272Z"},"bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","homepage":"https://github.com/ObscuritySRL/bun-win32#readme","keywords":["bun","ffi","win32","windows","ncrypt","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/ncrypt"},"description":"Zero-dependency, zero-overhead Win32 NCRYPT bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/ncrypt\r\n\r\nZero-dependency, zero-overhead Win32 Ncrypt bindings for [Bun](https://bun.sh) on Windows.\r\n\r\n## Overview\r\n\r\n`@bun-win32/ncrypt` exposes the `ncrypt.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Ncrypt`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\r\n\r\nThe bindings are strongly typed for a smooth DX in TypeScript.\r\n\r\n## Features\r\n\r\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\r\n- Direct FFI to `ncrypt.dll` (CNG key storage, persisted keys, signing, attestation, and DPAPI-NG data protection).\r\n- In-source docs in `structs/Ncrypt.ts` with links to Microsoft Docs.\r\n- Lazy binding on first call; optional eager preload (`Ncrypt.Preload()`).\r\n- No wrapper overhead; calls map 1:1 to native APIs.\r\n- Strongly-typed Win32 aliases (see `types/Ncrypt.ts`).\r\n\r\n## Requirements\r\n\r\n- [Bun](https://bun.sh) runtime\r\n- Windows 10 or later\r\n\r\n## Installation\r\n\r\n```sh\r\nbun add @bun-win32/ncrypt\r\n```\r\n\r\n## Quick Start\r\n\r\n```ts\r\nimport { read } from 'bun:ffi';\r\nimport Ncrypt, { MS_KEY_STORAGE_PROVIDER, NCRYPT_RSA_ALGORITHM } from '@bun-win32/ncrypt';\r\n\r\n// Open the Microsoft Software KSP.\r\nconst provBuf = Buffer.alloc(8);\r\nconst provName = Buffer.from(MS_KEY_STORAGE_PROVIDER + '\\0', 'utf16le');\r\nNcrypt.NCryptOpenStorageProvider(provBuf.ptr!, provName.ptr!, 0);\r\nconst hProv = BigInt(read.u64(provBuf.ptr!, 0));\r\n\r\n// Ask whether RSA is supported.\r\nconst alg = Buffer.from(NCRYPT_RSA_ALGORITHM + '\\0', 'utf16le');\r\nconst status = Ncrypt.NCryptIsAlgSupported(hProv, alg.ptr!, 0);\r\nconsole.log('RSA supported:', status === 0);\r\n\r\nNcrypt.NCryptFreeObject(hProv);\r\n```\r\n\r\n> [!NOTE]\r\n> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.\r\n\r\n## Examples\r\n\r\nRun the included examples:\r\n\r\n```sh\r\nbun run example:provider-audit \"secret message\"\r\nbun run example:rsa-sign-verify\r\n```\r\n\r\n## Notes\r\n\r\n- Either rely on lazy binding or call `Ncrypt.Preload()`.\r\n- Windows only. Bun runtime required.\n- **SAL types & naming:** nullability is in the **type** — `Optional<T>` (formally optional, SAL `_*opt_`) and `Nullable<T>` (plain `[in]`/`[out]` the docs say can be NULL), the null sentinel derived from `T` (`null` for pointers `LP*`/`P*`, `0n` for handles/by-value addresses); direction is in the **parameter name** — `_out` (`_Out_`), `_in_out` (`_Inout_`), `_In_` bare. See `AI.md` and the repo `AGENTS.md`.\n","readmeFilename":"README.md"}