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