@ddunigma/node 1.1.3 → 1.1.4

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 CHANGED
@@ -1,92 +1,80 @@
1
- ## ddunigma-node
1
+ # DDU ENIGMA - Node.js
2
2
 
3
- ### Overview
3
+ 데이터를 특정 문자셋으로 인코딩하는 Node.js 라이브러리입니다.
4
4
 
5
- Node.js implementation of [ddunigma](https://github.com/i3l3/ddunigma) (Python original)
5
+ ## 크레딧
6
6
 
7
- ### Credits
7
+ - 원본 Python 구현: [@i3ls](https://github.com/i3l3), [@gunu3371](https://github.com/gunu3371)
8
+ - 원본 저장소: [ddunigma](https://github.com/i3l3/ddunigma)
8
9
 
9
- - Original Python Implementation by:
10
- - [@i3ls](https://github.com/i3l3)
11
- - [@gunu3371](https://github.com/gunu3371)
12
- - Original Repository: [ddunigma](https://github.com/i3l3/ddunigma)
10
+ ## 설치
13
11
 
14
- ### Usage
12
+ ```bash
13
+ npm install @ddunigma/node
14
+ ```
15
+
16
+ ## 기본 사용법
15
17
 
16
- - Use Basic
17
- ```js
18
+ ### 간단한 문자열 인코딩/디코딩
19
+
20
+ ```typescript
18
21
  import { Ddu64 } from "@ddunigma/node";
19
22
 
20
- const ddu64 = new Ddu64(); //default encode utf-8
23
+ // 커스텀 charset으로 인코더 생성
24
+ const encoder = new Ddu64("우따야", "뭐");
25
+
26
+ const text = "Hello World!";
27
+ const encoded = encoder.encode(text);
28
+ console.log(encoded); // 우따야뭐우따... (인코딩된 문자열)
29
+
30
+ const decoded = encoder.decode(encoded);
31
+ console.log(decoded); // "Hello World!"
32
+ ```
33
+
34
+ ### 미리 정의된 Charset 사용
21
35
 
22
- const answer = "뜌땨어 고수가 될거야!";
36
+ ```typescript
37
+ import { Ddu64, DduSetSymbol } from "@ddunigma/node";
23
38
 
24
- const encoded = ddu64.encode(answer);
25
- console.log(encoded);
26
- //뜌.뜌이뜌.뜌땨뜌?뜌이뜌땨뜌야뜌.뜌이뜌.뜌땨뜌이뜌?뜌!뜌뜌뜌.뜌우뜌땨뜌땨뜌우뜌이뜌?뜌야뜌땨뜌뜌뜌땨뜌?뜌!뜌이뜌?뜌우뜌!뜌뜌뜌땨뜌?뜌?뜌이뜌땨뜌뜌뜌야뜌?뜌땨뜌?뜌!뜌이뜌?뜌뜌뜌야뜌뜌뜌뜌뜌이뜌뜌뜌우뜌!뜌우뜌야뜌야뜌땨뜌이뜌뜌뜌우뜌!뜌이뜌!뜌야뜌우뜌우뜌뜌뜌우뜌!뜌야뜌야뜌!뜌우뜌우뜌?뜌뜌뜌야뜌땨
27
- const decoded = ddu64.decode(encoded);
28
- console.log(decoded);
29
- //뜌땨어 고수가 될거야!
39
+ // ONECHARSET (64개 문자)
40
+ const encoder1 = new Ddu64(undefined, undefined, {
41
+ dduSetSymbol: DduSetSymbol.ONECHARSET
42
+ });
30
43
 
31
- //Encoding Shorter
32
- const encodedShorter = ddu64.encode(answer, { usePowerOfTwo: true });
33
- console.log(encodedShorter);
34
- //.이.땨?이땨야.이.땨이?!뜌.우땨땨우이?야땨뜌땨?!이?우!뜌땨??이땨뜌야?땨?!이?뜌야뜌뜌이뜌우!우야야땨이뜌우!이!야우우뜌우!야야!우우?뜌야땨
35
- const decodedShorter = ddu64.decode(encodedShorter, { usePowerOfTwo: true });
36
- console.log(decodedShorter);
37
- //뜌땨어 고수가 될거야!
44
+ // DDU (8개 문자)
45
+ const encoder2 = new Ddu64(undefined, undefined, {
46
+ dduSetSymbol: DduSetSymbol.DDU
47
+ });
48
+
49
+ // TWOCHARSET (1024개 문자)
50
+ const encoder3 = new Ddu64(undefined, undefined, {
51
+ dduSetSymbol: DduSetSymbol.TWOCHARSET
52
+ });
53
+
54
+ // THREECHARSET (32768개 문자)
55
+ const encoder4 = new Ddu64(undefined, undefined, {
56
+ dduSetSymbol: DduSetSymbol.THREECHARSET
57
+ });
58
+
59
+ const text = "안녕하세요";
60
+ const encoded = encoder1.encode(text);
61
+ const decoded = encoder1.decode(encoded);
38
62
  ```
39
63
 
40
- - Use Custom Encoding CharSet
41
- ```js
64
+ ### 커스텀 Charset 사용
65
+
66
+ ```typescript
42
67
  import { Ddu64 } from "@ddunigma/node";
68
+
43
69
  const koreanChars = [
44
- // 계열
45
- "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
46
- "뜛", "뜜", "뜝", "뜞", "뜟", "뜠", "뜡", "뜢", "뜣", "뜤", "뜥", "뜦", "뜧", "뜨", "뜩",
47
- "뜪", "뜫", "뜬", "뜭", "뜮", "뜯", "뜰", "뜱", "뜲", "뜳", "뜴", "뜵", "뜶", "뜷", "뜸",
48
- "뜹", "뜺", "뜻", "뜼", "뜽", "뜾", "뜿",
49
- // 땨 계열
50
- "땨", "땩", "땪", "땫", "땬", "땭", "땮", "땯", "땰", "땱", "땲", "땳", "땴", "땵", "땶",
51
- "땷", "땸", "땹", "땺", "땻", "땼", "땽", "땾", "땿", "떀", "떁", "떂", "떃", "떄", "떅",
52
- "떆", "떇", "떈", "떉", "떊", "떋", "떌", "떍", "떎", "떏", "떐", "떑", "떒", "떓", "떔",
53
- "떕", "떖", "떗", "떘", "떙", "떚", "떛",
54
- // 우 계열
55
- "우", "욱", "욲", "욳", "운", "울", "욶", "욷", "움", "웁", "웂", "웃", "웄", "웅", "웆",
56
- "웇", "워", "웍", "웎", "웏", "원", "월", "웒", "웓", "월", "웕", "웖", "웗", "웘", "웙",
57
- "웚", "웛", "위", "윅", "윆", "윇", "윈", "윉", "윊", "윋", "윌", "윍", "윎", "윏", "윐",
58
- "윑", "윒", "윓", "윔", "윕", "윖",
59
- // 따 계열
60
- "따", "딱", "딲", "딳", "딴", "딵", "딶", "딷", "딸", "딹", "딺", "딻", "딼", "딽", "딾",
61
- "딿", "땀", "땁", "땂", "땃", "땄", "땅", "땆", "땇", "땈", "땉", "땊", "땋", "때", "땍",
62
- "땎", "땏", "때", "땑", "땒", "땓", "땔", "땕", "땖", "땗", "땘", "땙", "땚", "땛", "땜",
63
- "땝", "땞", "땟", "땠", "땡", "땢",
64
- // 야 계열
65
- "야", "약", "얂", "얃", "얄", "얅", "얆", "얇", "얈", "얉", "얊", "얋", "얌", "얍", "얎",
66
- "얏", "양", "양", "얒", "얓", "얔", "얕", "얖", "얗", "얘", "얙", "얚", "얛", "얜", "얝",
67
- "얞", "얟", "얠", "얡", "얢", "얣", "얤", "얥", "얦", "얧", "얨", "얩", "얪", "얫", "얬",
68
- "얭", "얮", "얯", "얰", "얱"
70
+ "", "뜍", "뜎", "뜏", "뜐", "뜑", "뜒", "뜓", "뜔", "뜕", "뜖", "뜗", "뜘", "뜙", "뜚", "뜛",
71
+ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "뜫",
72
+ // ... 256개 문자
69
73
  ];
70
74
 
71
- const ddu64 = new Ddu64(koreanChars,'');
72
-
73
- const answer = "안녕하세요";
74
- const encoded = ddu64.encode(answer);
75
- console.log(encoded);
76
- //뜌얞뜌윑뜌위뜌얝뜌웙뜌윑뜌얟뜌윑뜌윔뜌얞뜌웘뜌땍뜌얞뜌윖뜌윐
77
- const decoded = ddu64.decode(encoded);
78
- console.log(decoded);
79
- //안녕하세요
80
-
81
- //Encoding Shorter
82
- const encodedShorter = ddu64.encode(answer, { usePowerOfTwo: true });
83
- console.log(encodedShorter);
84
- //얞윑위얝웙윑얟윑윔얞웘땍얞윖윐
85
- const decodedShorter = ddu64.decode(encodedShorter, { usePowerOfTwo: true });
86
- console.log(decodedShorter);
87
- //안녕하세요
88
- ```
89
-
90
- Add Ddu128, Ddu512, Ddu1024
91
- It's UrlSafeEncoding
75
+ const encoder = new Ddu64(koreanChars, "");
92
76
 
77
+ const text = "안녕하세요12";
78
+ const encoded = encoder.encode(text);
79
+ const decoded = encoder.decode(encoded);
80
+ ```
@@ -13,45 +13,8 @@ export declare class Ddu64 extends BaseDdu {
13
13
  private readonly binaryChunkToIntFn;
14
14
  private readonly indexToBinaryCache;
15
15
  constructor(dduChar?: string[] | string, paddingChar?: string, dduOptions?: DduConstructorOptions);
16
- /**
17
- * charset 초기화 (커스텀 또는 미리 정의된 charset)
18
- */
19
- private initializeCharSet;
20
- /**
21
- * 커스텀 charset 처리
22
- */
23
- private processCustomCharSet;
24
- /**
25
- * 미리 정의된 charset 처리
26
- */
27
- private processPredefinedCharSet;
28
- /**
29
- * 기본 charset 처리
30
- */
31
- private processDefaultCharSet;
32
- /**
33
- * fallback charset 가져오기
34
- * 우선순위: dduOptions.dduSetSymbol > dduDefaultConstructorOptions.dduSetSymbol > DduSetSymbol.ONECHARSET
35
- */
36
- private getFallbackCharSet;
37
16
  private normalizeCharSet;
38
17
  private getBinaryFromIndex;
39
- /**
40
- * string 또는 배열을 문자 배열로 변환
41
- */
42
- private convertToCharArray;
43
- /**
44
- * 숫자가 2의 제곱수인지 확인
45
- */
46
- private isPowerOfTwo;
47
- /**
48
- * usePowerOfTwo 옵션 적용
49
- */
50
- private applyPowerOfTwoOption;
51
- /**
52
- * 2글자 이상의 문자셋에서 조합으로 인한 중복을 검증
53
- * 예: ["AB", "CD"] + padding "AB" 또는 "A" + "B" = "AB" 같은 경우 감지
54
- */
55
18
  private validateCombinationDuplicates;
56
19
  encode(input: Buffer | string, _options?: DduOptions): string;
57
20
  decode(input: string, _options?: DduOptions): string;