@ddunigma/node 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +217 -198
- package/dist/browser.cjs +7 -0
- package/dist/browser.d.cts +217 -0
- package/dist/browser.d.ts +217 -0
- package/dist/browser.js +7 -0
- package/dist/core-BccIjoLZ.d.cts +663 -0
- package/dist/core-BccIjoLZ.d.ts +663 -0
- package/dist/core.cjs +7 -0
- package/dist/core.d.cts +1 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +7 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +62 -743
- package/dist/index.d.ts +62 -743
- package/dist/index.js +6 -4
- package/dist/wasm/codec.wasm +0 -0
- package/package.json +24 -3
- package/dist/DduStream-NP3CMCKK.js +0 -2
- package/dist/chunk-FVBZKVPE.js +0 -4
package/README.md
CHANGED
|
@@ -8,6 +8,13 @@ V2 추가사항
|
|
|
8
8
|
|
|
9
9
|
- 이제 한글 종성 결합 시스템을 활용하여 8개 기본 문자 × 8개 종성으로 64가지 조합을 만들어, 6비트를 한 글자로 표현합니다.
|
|
10
10
|
|
|
11
|
+
### Credits
|
|
12
|
+
|
|
13
|
+
- Original Python Implementation by:
|
|
14
|
+
- [@i3ls](https://github.com/i3l3)
|
|
15
|
+
- [@gunu3371](https://github.com/gunu3371)
|
|
16
|
+
- Original Repository: [ddunigma](https://github.com/i3l3/ddunigma)
|
|
17
|
+
|
|
11
18
|
## Requirements
|
|
12
19
|
|
|
13
20
|
- **Node.js >= 18.0.0**
|
|
@@ -36,305 +43,317 @@ dduV1.decode(".우땨땨이?땨뜌.이.뜌이?이!.우우땨이?우뜌.우땨뜌
|
|
|
36
43
|
|
|
37
44
|
---
|
|
38
45
|
|
|
39
|
-
##
|
|
40
|
-
|
|
41
|
-
### 인코딩/디코딩
|
|
46
|
+
## Binary Data
|
|
42
47
|
|
|
43
48
|
```typescript
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const encoder = new Ddu64();
|
|
49
|
+
const ddu = new Ddu64();
|
|
50
|
+
const input = new Uint8Array([0, 1, 127, 128, 255]);
|
|
47
51
|
|
|
48
|
-
const encoded =
|
|
49
|
-
const
|
|
52
|
+
const encoded = ddu.encode(input);
|
|
53
|
+
const bytes = ddu.decodeToUint8Array(encoded);
|
|
54
|
+
const buffer = ddu.decodeToBuffer(encoded); // Node.js Buffer
|
|
50
55
|
```
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
## Presets
|
|
53
58
|
|
|
54
59
|
```typescript
|
|
55
|
-
|
|
56
|
-
const encoder = new Ddu64("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", "=");
|
|
60
|
+
import { Ddu64, DduSetSymbol } from "@ddunigma/node";
|
|
57
61
|
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
// 기본값 - 한글 종성 결합 64문자
|
|
63
|
+
new Ddu64();
|
|
64
|
+
|
|
65
|
+
// 구버전 호환 8문자
|
|
66
|
+
new Ddu64(undefined, undefined, { dduSetSymbol: DduSetSymbol.DDU_V1 });
|
|
67
|
+
|
|
68
|
+
// 영문+숫자 64문자
|
|
69
|
+
new Ddu64(undefined, undefined, { dduSetSymbol: DduSetSymbol.ONECHARSET });
|
|
62
70
|
```
|
|
63
71
|
|
|
64
|
-
|
|
72
|
+
| Symbol | 문자 수 | 설명 |
|
|
73
|
+
| ------------ | ------: | ---------------------------------- |
|
|
74
|
+
| `DDU` | 64 | 한글 기본 문자 8개 × 종성 8개 조합 |
|
|
75
|
+
| `DDU_V1` | 8 | 기존 8문자 쌍 방식 (하위 호환) |
|
|
76
|
+
| `ONECHARSET` | 64 | 영문, 숫자, 일부 특수문자 |
|
|
65
77
|
|
|
66
|
-
|
|
67
|
-
| ------------ | ------- | ---- | ------------------------------------ |
|
|
68
|
-
| `DDU` | 64 | 6 | 한글 종성 결합 (8 기본문자 × 8 종성) |
|
|
69
|
-
| `DDU_V1` | 8 | 3 | 구버전 호환 (뜌땨이우야!?.) |
|
|
70
|
-
| `ONECHARSET` | 64 | 6 | 영문 + 숫자 + 특수문자 |
|
|
78
|
+
## Custom Charset
|
|
71
79
|
|
|
72
80
|
```typescript
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
// 문자열로 직접 지정
|
|
82
|
+
const base64Like = new Ddu64(
|
|
83
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
84
|
+
"=",
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// 한글 종성 조합으로 커스텀 charset 생성
|
|
88
|
+
const hangulCoda = new Ddu64(["가", "나", "다", "라"], "뭐", {
|
|
89
|
+
codaChar: ["", "ㄱ", "ㄲ", "ㄷ"],
|
|
77
90
|
});
|
|
91
|
+
// → 가, 각, 갂, 갇, 나, 낙, 낚, 낟, 다, 닥, 닦, 닫, 라, 락, 랔, 랗 (16문자)
|
|
78
92
|
```
|
|
79
93
|
|
|
80
|
-
|
|
94
|
+
## CharsetBuilder
|
|
81
95
|
|
|
82
|
-
|
|
96
|
+
```typescript
|
|
97
|
+
import { CharsetBuilder, Ddu64 } from "@ddunigma/node";
|
|
83
98
|
|
|
84
|
-
|
|
99
|
+
// Base64에서 혼동 문자 제거 후 2의 제곱수로 맞추기
|
|
100
|
+
const { charset, padding } = CharsetBuilder.base64()
|
|
101
|
+
.excludeConfusing()
|
|
102
|
+
.limitToPowerOfTwo()
|
|
103
|
+
.buildWithPadding();
|
|
85
104
|
|
|
86
|
-
|
|
105
|
+
const ddu = new Ddu64(charset, padding);
|
|
87
106
|
|
|
88
|
-
|
|
89
|
-
const
|
|
107
|
+
// 유니코드 범위에서 생성
|
|
108
|
+
const chars = CharsetBuilder.fromUnicodeRange(0x4e00, 0x4e3f)
|
|
109
|
+
.shuffle(12345)
|
|
110
|
+
.limitToPowerOfTwo()
|
|
111
|
+
.build();
|
|
112
|
+
```
|
|
90
113
|
|
|
91
|
-
|
|
92
|
-
const encoded = encoder.encode(longText, { compress: true });
|
|
93
|
-
const decoded = encoder.decode(encoded);
|
|
114
|
+
## Compression
|
|
94
115
|
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
compress: true,
|
|
98
|
-
compressionAlgorithm: "brotli"
|
|
99
|
-
compressionLevel: 6,
|
|
116
|
+
```typescript
|
|
117
|
+
const ddu = new Ddu64(undefined, undefined, {
|
|
118
|
+
compress: true, // 압축 활성화
|
|
119
|
+
compressionAlgorithm: "deflate", // "deflate" | "brotli"
|
|
120
|
+
compressionLevel: 6, // deflate: 0-9, brotli: 0-11
|
|
100
121
|
});
|
|
122
|
+
|
|
123
|
+
const encoded = ddu.encode("A".repeat(1000)); // 압축되어 짧아짐
|
|
124
|
+
const decoded = ddu.decode(encoded);
|
|
101
125
|
```
|
|
102
126
|
|
|
103
|
-
|
|
127
|
+
압축은 원본보다 작아질 때만 적용됩니다. 압축 결과가 더 크면 비압축으로 저장됩니다.
|
|
104
128
|
|
|
105
|
-
|
|
129
|
+
## Encryption
|
|
106
130
|
|
|
107
131
|
```typescript
|
|
108
|
-
|
|
132
|
+
// SHA-256 키 파생 (기본)
|
|
133
|
+
const ddu = new Ddu64(undefined, undefined, {
|
|
109
134
|
encryptionKey: "my-secret-key",
|
|
110
135
|
});
|
|
111
136
|
|
|
112
|
-
const encoded =
|
|
113
|
-
const decoded =
|
|
137
|
+
const encoded = ddu.encode("secret message");
|
|
138
|
+
const decoded = ddu.decode(encoded); // 같은 키로만 복호화 가능
|
|
139
|
+
|
|
140
|
+
// PBKDF2 키 파생
|
|
141
|
+
const dduPbkdf2 = new Ddu64(undefined, undefined, {
|
|
142
|
+
encryptionKey: "user password",
|
|
143
|
+
keyDerivation: {
|
|
144
|
+
algorithm: "pbkdf2",
|
|
145
|
+
salt: "app-specific-salt",
|
|
146
|
+
iterations: 210_000,
|
|
147
|
+
hash: "SHA-256",
|
|
148
|
+
},
|
|
149
|
+
});
|
|
114
150
|
```
|
|
115
151
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
CRC32 체크섬으로 데이터 무결성을 검증합니다.
|
|
152
|
+
## Checksum
|
|
119
153
|
|
|
120
154
|
```typescript
|
|
121
|
-
const
|
|
155
|
+
const ddu = new Ddu64(undefined, undefined, { checksum: true });
|
|
122
156
|
|
|
123
|
-
const encoded =
|
|
124
|
-
const decoded =
|
|
125
|
-
// 데이터 변조 시 에러 발생
|
|
157
|
+
const encoded = ddu.encode("data"); // CRC32 체크섬 포함
|
|
158
|
+
const decoded = ddu.decode(encoded); // 무결성 검증 후 반환
|
|
126
159
|
```
|
|
127
160
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
`+`, `/`, `=` 를 URL 안전 문자(`-`, `_`, `.`)로 변환합니다.
|
|
161
|
+
## URL-Safe
|
|
131
162
|
|
|
132
163
|
```typescript
|
|
133
|
-
const
|
|
164
|
+
const ddu = new Ddu64("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", "=", {
|
|
134
165
|
urlSafe: true,
|
|
135
166
|
});
|
|
136
|
-
```
|
|
137
167
|
|
|
138
|
-
|
|
168
|
+
// +→- /→_ =→. 로 자동 변환
|
|
169
|
+
const encoded = ddu.encode("URL safe text");
|
|
170
|
+
```
|
|
139
171
|
|
|
140
|
-
|
|
172
|
+
## Chunking
|
|
141
173
|
|
|
142
174
|
```typescript
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
const encoded = encoder.encode(data, {
|
|
175
|
+
const ddu = new Ddu64(undefined, undefined, {
|
|
146
176
|
chunkSize: 76,
|
|
147
177
|
chunkSeparator: "\n",
|
|
148
178
|
});
|
|
149
|
-
// 디코딩 시 구분자 자동 제거
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### 비동기 처리
|
|
153
|
-
|
|
154
|
-
대용량 데이터에서 이벤트 루프 블로킹을 방지합니다.
|
|
155
179
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const decoded = await encoder.decodeAsync(encoded);
|
|
159
|
-
const buffer = await encoder.decodeToBufferAsync(encoded);
|
|
180
|
+
const encoded = ddu.encode("long data ".repeat(100));
|
|
181
|
+
// 76자마다 줄바꿈 삽입
|
|
160
182
|
```
|
|
161
183
|
|
|
162
|
-
|
|
184
|
+
## Obfuscation (한글 난독화)
|
|
163
185
|
|
|
164
186
|
```typescript
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
},
|
|
187
|
+
const ddu = new Ddu64(undefined, undefined, {
|
|
188
|
+
encryptionKey: "secret",
|
|
189
|
+
obfuscate: true, // 암호화 필수
|
|
169
190
|
});
|
|
191
|
+
|
|
192
|
+
const encoded = ddu.encode("hello");
|
|
193
|
+
// 출력이 한글 음절 블록(U+AC00–U+D7A3)으로 변환됨
|
|
170
194
|
```
|
|
171
195
|
|
|
172
|
-
|
|
196
|
+
## Async (브라우저 호환)
|
|
173
197
|
|
|
174
198
|
```typescript
|
|
175
|
-
|
|
176
|
-
|
|
199
|
+
// 브라우저에서는 async 메서드 사용
|
|
200
|
+
import { Ddu64 } from "@ddunigma/node/browser";
|
|
201
|
+
|
|
202
|
+
const ddu = new Ddu64();
|
|
203
|
+
const encoded = await ddu.encodeAsync("browser text");
|
|
204
|
+
const decoded = await ddu.decodeAsync(encoded);
|
|
177
205
|
```
|
|
178
206
|
|
|
179
|
-
|
|
207
|
+
Node.js에서도 async 메서드를 사용할 수 있습니다. 브라우저 진입점(`@ddunigma/node/browser`)은 Node.js 내장 모듈을 임포트하지 않습니다.
|
|
208
|
+
|
|
209
|
+
## Web Streams
|
|
180
210
|
|
|
181
211
|
```typescript
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
212
|
+
import { Ddu64, createReadableEncodeStream, createReadableDecodeStream } from "@ddunigma/node";
|
|
213
|
+
|
|
214
|
+
const ddu = new Ddu64(undefined, undefined, {
|
|
215
|
+
compress: true,
|
|
216
|
+
encryptionKey: "stream-key",
|
|
185
217
|
});
|
|
186
|
-
```
|
|
187
218
|
|
|
188
|
-
|
|
219
|
+
const encodedStream = readableByteStream.pipeThrough(
|
|
220
|
+
createReadableEncodeStream(ddu, { compress: true }),
|
|
221
|
+
);
|
|
189
222
|
|
|
190
|
-
|
|
223
|
+
const decodedStream = encodedStream.pipeThrough(createReadableDecodeStream(ddu));
|
|
224
|
+
```
|
|
191
225
|
|
|
192
|
-
|
|
226
|
+
## WASM Acceleration
|
|
193
227
|
|
|
194
228
|
```typescript
|
|
195
|
-
import {
|
|
196
|
-
|
|
197
|
-
// 유니코드 범위
|
|
198
|
-
CharsetBuilder.fromUnicodeRange(0x4e00, 0x4e3f).build();
|
|
229
|
+
import { Ddu64, preloadWasm } from "@ddunigma/node";
|
|
199
230
|
|
|
200
|
-
//
|
|
201
|
-
CharsetBuilder.base64().excludeConfusing().build();
|
|
231
|
+
await preloadWasm(); // 선택적 사전 로드
|
|
202
232
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
.shuffle(12345)
|
|
207
|
-
.build();
|
|
233
|
+
const ddu = new Ddu64(undefined, undefined, {
|
|
234
|
+
wasmThreshold: 4096, // 이 크기 이상일 때 WASM 사용
|
|
235
|
+
});
|
|
208
236
|
|
|
209
|
-
|
|
210
|
-
const { charset, padding } = CharsetBuilder.base64().buildWithPadding();
|
|
237
|
+
const encoded = ddu.encode(new Uint8Array(1024 * 1024));
|
|
211
238
|
```
|
|
212
239
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
## DduPipeline
|
|
240
|
+
WASM을 사용할 수 없으면 JavaScript로 자동 폴백됩니다.
|
|
216
241
|
|
|
217
|
-
|
|
242
|
+
## Progress Callback
|
|
218
243
|
|
|
219
244
|
```typescript
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const pipeline = new DduPipeline().compress(6, "brotli").encrypt("secret-key").encode(new Ddu64());
|
|
245
|
+
const ddu = new Ddu64(undefined, undefined, { compress: true });
|
|
223
246
|
|
|
224
|
-
|
|
225
|
-
|
|
247
|
+
ddu.encode("data", {
|
|
248
|
+
onProgress: ({ percent, stage }) => {
|
|
249
|
+
console.log(`${stage}: ${percent}%`);
|
|
250
|
+
// stage: start → compress → encrypt → encode → done
|
|
251
|
+
},
|
|
252
|
+
});
|
|
226
253
|
```
|
|
227
254
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
## 스트림
|
|
231
|
-
|
|
232
|
-
대용량 파일을 메모리 효율적으로 처리합니다. 스트림 헤더로 압축/암호화를 자동 감지합니다.
|
|
255
|
+
## Stats
|
|
233
256
|
|
|
234
257
|
```typescript
|
|
235
|
-
|
|
236
|
-
|
|
258
|
+
const ddu = new Ddu64(undefined, undefined, { compress: true });
|
|
259
|
+
const stats = ddu.getStats("A".repeat(1000));
|
|
237
260
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
encryptionKey: "stream-key",
|
|
241
|
-
});
|
|
261
|
+
// { originalSize, encodedSize, compressedSize, compressionRatio, expansionRatio, charsetSize, bitLength }
|
|
262
|
+
```
|
|
242
263
|
|
|
243
|
-
|
|
244
|
-
.pipe(createEncodeStream(encoder))
|
|
245
|
-
.pipe(fs.createWriteStream("output.ddu"));
|
|
264
|
+
## Size Limits
|
|
246
265
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
266
|
+
```typescript
|
|
267
|
+
const ddu = new Ddu64(undefined, undefined, {
|
|
268
|
+
maxDecodedBytes: 10 * 1024 * 1024, // 디코딩 최대 크기 (기본 64MB)
|
|
269
|
+
maxDecompressedBytes: 50 * 1024 * 1024, // 압축해제 최대 크기 (기본 64MB)
|
|
270
|
+
});
|
|
250
271
|
```
|
|
251
272
|
|
|
252
273
|
---
|
|
253
274
|
|
|
254
|
-
## API
|
|
255
|
-
|
|
256
|
-
### `new Ddu64(dduChar?, paddingChar?, options?)`
|
|
257
|
-
|
|
258
|
-
| Parameter | Type | Description |
|
|
259
|
-
| ------------- | ----------------------- | ------------------------ |
|
|
260
|
-
| `dduChar` | `string \| string[]` | charset 문자열 또는 배열 |
|
|
261
|
-
| `paddingChar` | `string` | 패딩 문자 |
|
|
262
|
-
| `options` | `DduConstructorOptions` | 옵션 객체 |
|
|
263
|
-
|
|
264
|
-
**생성자 옵션:**
|
|
265
|
-
|
|
266
|
-
| Option | Type | Default | Description |
|
|
267
|
-
| ---------------------- | ----------------------- | ----------- | ----------------------------- |
|
|
268
|
-
| `dduSetSymbol` | `DduSetSymbol` | `DDU` | 프리셋 심볼 |
|
|
269
|
-
| `codaChar` | `string[]` | — | 종성 배열 (동적 charset 생성) |
|
|
270
|
-
| `encoding` | `BufferEncoding` | `'utf-8'` | 문자열 인코딩 |
|
|
271
|
-
| `compress` | `boolean` | `false` | 기본 압축 활성화 |
|
|
272
|
-
| `compressionAlgorithm` | `"deflate" \| "brotli"` | `'deflate'` | 압축 알고리즘 |
|
|
273
|
-
| `compressionLevel` | `number` | `6` | 압축 레벨 |
|
|
274
|
-
| `urlSafe` | `boolean` | `false` | URL-Safe 모드 |
|
|
275
|
-
| `encryptionKey` | `string` | — | AES-256-GCM 암호화 키 |
|
|
276
|
-
| `checksum` | `boolean` | `false` | CRC32 체크섬 |
|
|
277
|
-
| `chunkSize` | `number` | — | 청크 분할 크기 |
|
|
278
|
-
| `chunkSeparator` | `string` | `'\n'` | 청크 구분자 |
|
|
279
|
-
| `maxDecodedBytes` | `number` | `67108864` | 최대 디코딩 바이트 (64MB) |
|
|
280
|
-
| `maxDecompressedBytes` | `number` | `67108864` | 최대 압축해제 바이트 (64MB) |
|
|
281
|
-
| `throwOnError` | `boolean` | `false` | 초기화 오류 시 throw |
|
|
282
|
-
| `useRepeatPadding` | `boolean` | `false` | 패딩 문자 반복 방식 |
|
|
283
|
-
| `usePowerOfTwo` | `boolean` | `true` | 2의 제곱수 charset 강제 |
|
|
284
|
-
|
|
285
|
-
**메서드:**
|
|
286
|
-
|
|
287
|
-
| Method | Return | Description |
|
|
288
|
-
| ---------------------------------------- | ----------------- | -------------------- |
|
|
289
|
-
| `encode(data, options?)` | `string` | 인코딩 |
|
|
290
|
-
| `decode(encoded, options?)` | `string` | 디코딩 |
|
|
291
|
-
| `decodeToBuffer(encoded, options?)` | `Buffer` | Buffer로 디코딩 |
|
|
292
|
-
| `encodeAsync(data, options?)` | `Promise<string>` | 비동기 인코딩 |
|
|
293
|
-
| `decodeAsync(encoded, options?)` | `Promise<string>` | 비동기 디코딩 |
|
|
294
|
-
| `decodeToBufferAsync(encoded, options?)` | `Promise<Buffer>` | 비동기 Buffer 디코딩 |
|
|
295
|
-
| `getStats(data, options?)` | `DduEncodeStats` | 인코딩 통계 |
|
|
296
|
-
| `getCharSetInfo()` | `CharSetInfo` | charset 정보 |
|
|
297
|
-
|
|
298
|
-
**encode/decode 옵션 (DduOptions):**
|
|
299
|
-
|
|
300
|
-
| Option | Type | Description |
|
|
301
|
-
| ---------------------- | ----------------------- | -------------------- |
|
|
302
|
-
| `compress` | `boolean` | 압축 사용 |
|
|
303
|
-
| `compressionAlgorithm` | `"deflate" \| "brotli"` | 압축 알고리즘 |
|
|
304
|
-
| `compressionLevel` | `number` | 압축 레벨 |
|
|
305
|
-
| `checksum` | `boolean` | 체크섬 추가/검증 |
|
|
306
|
-
| `chunkSize` | `number` | 청크 분할 크기 |
|
|
307
|
-
| `chunkSeparator` | `string` | 청크 구분자 |
|
|
308
|
-
| `maxDecodedBytes` | `number` | 최대 디코딩 바이트 |
|
|
309
|
-
| `maxDecompressedBytes` | `number` | 최대 압축해제 바이트 |
|
|
310
|
-
| `onProgress` | `function` | 진행률 콜백 |
|
|
275
|
+
## API
|
|
311
276
|
|
|
312
|
-
|
|
277
|
+
```typescript
|
|
278
|
+
class Ddu64 {
|
|
279
|
+
encode(data: string | Uint8Array, options?: DduOptions): string;
|
|
280
|
+
decode(encoded: string, options?: DduOptions): string;
|
|
281
|
+
decodeToUint8Array(encoded: string, options?: DduOptions): Uint8Array;
|
|
282
|
+
decodeToBuffer(encoded: string, options?: DduOptions): Buffer;
|
|
283
|
+
|
|
284
|
+
encodeAsync(data: string | Uint8Array, options?: DduOptions): Promise<string>;
|
|
285
|
+
decodeAsync(encoded: string, options?: DduOptions): Promise<string>;
|
|
286
|
+
decodeToUint8ArrayAsync(encoded: string, options?: DduOptions): Promise<Uint8Array>;
|
|
287
|
+
decodeToBufferAsync(encoded: string, options?: DduOptions): Promise<Buffer>;
|
|
288
|
+
|
|
289
|
+
getStats(data: string | Uint8Array, options?: DduOptions): DduEncodeStats;
|
|
290
|
+
getCharSetInfo(): CharSetInfo;
|
|
291
|
+
|
|
292
|
+
static setWorkerPoolSize(n: number): void;
|
|
293
|
+
}
|
|
294
|
+
```
|
|
313
295
|
|
|
314
|
-
##
|
|
296
|
+
## Constructor Options
|
|
315
297
|
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
pnpm test:watch # 워치 모드
|
|
319
|
-
pnpm test:coverage # 커버리지
|
|
298
|
+
```typescript
|
|
299
|
+
new Ddu64(dduChar?, paddingChar?, options?);
|
|
320
300
|
```
|
|
321
301
|
|
|
322
|
-
|
|
302
|
+
| Option | Type | Default | 설명 |
|
|
303
|
+
| ---------------------- | ----------------------- | ----------- | --------------------- |
|
|
304
|
+
| `dduSetSymbol` | `DduSetSymbol` | `DDU` | 프리셋 선택 |
|
|
305
|
+
| `dduChar` | `string \| string[]` | - | 커스텀 charset |
|
|
306
|
+
| `paddingChar` | `string` | - | 패딩 문자 |
|
|
307
|
+
| `codaChar` | `string[]` | - | 종성 조합 문자 |
|
|
308
|
+
| `compress` | `boolean` | `false` | 압축 활성화 |
|
|
309
|
+
| `compressionAlgorithm` | `"deflate" \| "brotli"` | `"deflate"` | 압축 알고리즘 |
|
|
310
|
+
| `compressionLevel` | `number` | `6` | 압축 레벨 |
|
|
311
|
+
| `encryptionKey` | `string` | - | AES-256-GCM 암호화 키 |
|
|
312
|
+
| `keyDerivation` | `KeyDerivationOptions` | `sha256` | 키 파생 방식 |
|
|
313
|
+
| `checksum` | `boolean` | `false` | CRC32 체크섬 |
|
|
314
|
+
| `urlSafe` | `boolean` | `false` | URL-Safe 변환 |
|
|
315
|
+
| `obfuscate` | `boolean` | `false` | 한글 난독화 |
|
|
316
|
+
| `chunkSize` | `number` | - | 청크 분할 크기 |
|
|
317
|
+
| `chunkSeparator` | `string` | `"\n"` | 청크 구분자 |
|
|
318
|
+
| `maxDecodedBytes` | `number` | `67108864` | 디코딩 크기 제한 |
|
|
319
|
+
| `maxDecompressedBytes` | `number` | `67108864` | 압축해제 크기 제한 |
|
|
320
|
+
| `wasmThreshold` | `number` | `4096` | WASM 사용 임계값 |
|
|
321
|
+
| `throwOnError` | `boolean` | `false` | 초기화 에러 시 throw |
|
|
322
|
+
|
|
323
|
+
## Per-Call Options
|
|
324
|
+
|
|
325
|
+
`encode`, `decode`, `encodeAsync`, `decodeAsync` 등에서 호출별로 오버라이드 가능:
|
|
326
|
+
|
|
327
|
+
| Option | Type | 설명 |
|
|
328
|
+
| ---------------------- | ----------------------- | ------------------ |
|
|
329
|
+
| `compress` | `boolean` | 압축 사용 여부 |
|
|
330
|
+
| `compressionAlgorithm` | `"deflate" \| "brotli"` | 압축 알고리즘 |
|
|
331
|
+
| `compressionLevel` | `number` | 압축 레벨 |
|
|
332
|
+
| `encrypt` | `boolean` | 암호화 사용 여부 |
|
|
333
|
+
| `checksum` | `boolean` | 체크섬 사용 여부 |
|
|
334
|
+
| `obfuscate` | `boolean` | 난독화 사용 여부 |
|
|
335
|
+
| `chunkSize` | `number` | 청크 크기 |
|
|
336
|
+
| `maxDecodedBytes` | `number` | 디코딩 크기 제한 |
|
|
337
|
+
| `maxDecompressedBytes` | `number` | 압축해제 크기 제한 |
|
|
338
|
+
| `onProgress` | `(info) => void` | 진행률 콜백 |
|
|
339
|
+
|
|
340
|
+
## Entry Points
|
|
341
|
+
|
|
342
|
+
| Import Path | 용도 |
|
|
343
|
+
| ------------------------ | ------------------------------------- |
|
|
344
|
+
| `@ddunigma/node` | Node.js 전체 기능 (동기+비동기) |
|
|
345
|
+
| `@ddunigma/node/browser` | 브라우저 최적화 (Node.js 모듈 미포함) |
|
|
346
|
+
| `@ddunigma/node/core` | 최소 코어 (인코딩/디코딩만) |
|
|
347
|
+
|
|
348
|
+
## Build & Test
|
|
323
349
|
|
|
324
350
|
```bash
|
|
351
|
+
pnpm test
|
|
325
352
|
pnpm build
|
|
326
353
|
pnpm lint
|
|
327
354
|
pnpm bench
|
|
328
|
-
pnpm pack:check
|
|
329
355
|
```
|
|
330
356
|
|
|
331
|
-
---
|
|
332
|
-
|
|
333
|
-
## Credits
|
|
334
|
-
|
|
335
|
-
- Original: [@i3ls](https://github.com/i3l3), [@gunu3371](https://github.com/gunu3371)
|
|
336
|
-
- Repository: [ddunigma](https://github.com/i3l3/ddunigma)
|
|
337
|
-
|
|
338
357
|
## License
|
|
339
358
|
|
|
340
359
|
BSD-2-Clause
|