npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hwp-crypto

v0.1.2

Published

Decrypt password-protected HWP/HWPX files and extract text

Readme

hwp-crypto

Decrypt password-protected HWP/HWPX (한글) files and extract text.

  • HWP — HWP 5.0 EncryptVersion 4 (한글 7.0+)
  • HWPX — ODF-style AES-256-CBC encryption (한글 2010+)

Install

npm install hwp-crypto

Usage

Auto-detect format and decrypt

import { decrypt } from "hwp-crypto";
import { readFileSync } from "fs";

const encrypted = readFileSync("secret.hwp"); // or .hwpx
const decrypted = decrypt(encrypted, "password");

Extract text from a password-protected file

import { decrypt, extractText, extractTextHwpx, detectFormat } from "hwp-crypto";
import { readFileSync } from "fs";

const buf = readFileSync("secret.hwpx");
const decrypted = decrypt(buf, "password");

if (detectFormat(buf) === "hwpx") {
  console.log(extractTextHwpx(decrypted));
} else {
  console.log(extractText(decrypted));
}

Format-specific APIs

import { decryptHwp, decryptHwpx } from "hwp-crypto";

// HWP 5.0
const hwpResult = decryptHwp(hwpBuffer, "password");

// HWPX
const hwpxResult = decryptHwpx(hwpxBuffer, "password");

Decrypt and save

import { decryptFile } from "hwp-crypto";

decryptFile("secret.hwp", "password", "decrypted.hwp");
decryptFile("secret.hwpx", "password", "decrypted.hwpx");

CLI

npx hwp-crypto input.hwp mypassword output.hwp
npx hwp-crypto input.hwpx mypassword output.hwpx

API

decrypt(input: Buffer, password: string): Buffer

Auto-detects HWP/HWPX format and decrypts. Returns a new buffer that can be opened without a password.

decryptFile(inputPath: string, password: string, outputPath: string): void

Auto-detecting file-based version of decrypt.

decryptHwp(input: Buffer, password: string): Buffer

Decrypts a password-protected HWP 5.0 file buffer.

decryptHwpx(input: Buffer, password: string): Buffer

Decrypts a password-protected HWPX file buffer.

extractText(input: Buffer): string

Extracts text from an HWP file buffer.

extractTextHwpx(input: Buffer): string

Extracts text from an HWPX file buffer.

detectFormat(input: Buffer): "hwp" | "hwpx" | "unknown"

Detects file format from magic bytes.

deriveKey(password: string): Buffer

Derives the AES-128 key from a password (HWP 5.0, advanced use).

deriveHwpxKey(password: string | Buffer, salt: Buffer, iterations: number, keySize: number): Buffer

Derives the AES-256 key from a password (HWPX, advanced use).

How it works

HWP 5.0

Custom 1-bit CFB stream cipher built on AES-128-ECB. Password → byte interleaving + SHA-1 → 16-byte AES key. Encrypted streams (DocInfo, BodyText/Section*, BinData, Scripts) are decrypted and the FileHeader password flag is cleared.

HWPX

ODF-style per-file encryption within a ZIP container. Password → SHA-256 → PBKDF2-HMAC-SHA1 → 32-byte AES key. Each encrypted XML entry is decrypted with AES-256-CBC, then deflate-decompressed. Checksum verification uses SHA-256 of the first 1024 bytes.

Acknowledgements

본 제품은 한글과컴퓨터의 한글 문서 파일(.hwp) 공개 문서를 참고하여 개발하였습니다.

License

MIT