@irfanshadikrishad/cipher 1.3.3 → 1.4.1

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
@@ -55,6 +55,7 @@ This library provides implementations of various classical and modern ciphers:
55
55
  | [AES](/docs/en/ciphers/AES.md) | Symmetric Block Cipher | Yes | High | Also known as, Rijndael |
56
56
  | [DES](/docs/en/ciphers/DES.md) | Symmetric Block Cipher | Yes | Medium | 56-bit key, Used in legacy systems, replaced by AES |
57
57
  | [ECC](/docs/en/ciphers/ECC.md) | Asymmetric (Public-Key Cryptography) | Yes | Very High | Used in modern systems like Bitcoin, TLS, JWT, etc. |
58
+ | [ROT13](/docs/en/ciphers/ROT13.md) | Substitution (Caesar variant) | No | Very Low | Simple text obfuscation, not secure |
58
59
 
59
60
  More ciphers coming soon...
60
61
 
package/dist/Cipher.d.ts CHANGED
@@ -6,6 +6,7 @@ import { Caesar } from './ciphers/Caesar.js';
6
6
  import { DES } from './ciphers/DES.js';
7
7
  import { ECC } from './ciphers/ECC.js';
8
8
  import { Playfair } from './ciphers/Playfair.js';
9
+ import { ROT13 } from './ciphers/ROT13.js';
9
10
  import { Salsa20 } from './ciphers/Salsa20.js';
10
11
  import { Vigenere } from './ciphers/Vigenere.js';
11
12
  export declare abstract class Cipher {
@@ -63,6 +64,10 @@ export declare abstract class Cipher {
63
64
  * Elliptic-curve cryptography (ECC) is an approach to public-key cryptography based on the algebraic structure of elliptic curves over finite fields.
64
65
  */
65
66
  static ECC: typeof ECC;
67
+ /**
68
+ * ROT13 is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the Latin alphabet.
69
+ */
70
+ static ROT13: typeof ROT13;
66
71
  abstract encrypt(text: string): string | Promise<string>;
67
72
  abstract decrypt(text: string): string | Promise<string>;
68
73
  }
@@ -0,0 +1,7 @@
1
+ import { Cipher } from '../Cipher.js';
2
+ export declare class ROT13 extends Cipher {
3
+ constructor();
4
+ private rotate;
5
+ encrypt(text: string): string;
6
+ decrypt(text: string): string;
7
+ }
@@ -0,0 +1,27 @@
1
+ import { Cipher } from '../Cipher.js';
2
+ export class ROT13 extends Cipher {
3
+ constructor() {
4
+ super();
5
+ }
6
+ rotate(char) {
7
+ const code = char.charCodeAt(0);
8
+ // A–Z
9
+ if (code >= 65 && code <= 90) {
10
+ return String.fromCharCode(((code - 65 + 13) % 26) + 65);
11
+ }
12
+ // a–z
13
+ if (code >= 97 && code <= 122) {
14
+ return String.fromCharCode(((code - 97 + 13) % 26) + 97);
15
+ }
16
+ return char;
17
+ }
18
+ encrypt(text) {
19
+ return text
20
+ .split('')
21
+ .map((char) => this.rotate(char))
22
+ .join('');
23
+ }
24
+ decrypt(text) {
25
+ return this.encrypt(text);
26
+ }
27
+ }
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ import { Caesar } from './ciphers/Caesar.js';
7
7
  import { DES } from './ciphers/DES.js';
8
8
  import { ECC } from './ciphers/ECC.js';
9
9
  import { Playfair } from './ciphers/Playfair.js';
10
+ import { ROT13 } from './ciphers/ROT13.js';
10
11
  import { Salsa20 } from './ciphers/Salsa20.js';
11
12
  import { Vigenere } from './ciphers/Vigenere.js';
12
13
  Cipher.Caesar = Caesar;
@@ -19,4 +20,5 @@ Cipher.ADFGVX = ADFGVX;
19
20
  Cipher.AES = AES;
20
21
  Cipher.DES = DES;
21
22
  Cipher.ECC = ECC;
23
+ Cipher.ROT13 = ROT13;
22
24
  export { Cipher };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@irfanshadikrishad/cipher",
3
3
  "description": "A versatile and secure cryptographic library for implementing various cipher algorithms in Node.js applications with zero/0 dependencies.",
4
- "version": "1.3.3",
4
+ "version": "1.4.1",
5
5
  "author": {
6
6
  "name": "Irfan Shadik Rishad"
7
7
  },
@@ -51,11 +51,11 @@
51
51
  "@typescript-eslint/eslint-plugin": "^8.38.0",
52
52
  "@typescript-eslint/parser": "^8.38.0",
53
53
  "eslint": "^9.34.0",
54
- "globals": "^16.3.0",
54
+ "globals": "^16.5.0",
55
55
  "husky": "^9.1.7",
56
- "jest": "^30.1.3",
56
+ "jest": "^30.2.0",
57
57
  "prettier": "^3.6.2",
58
- "ts-jest": "^29.4.1",
58
+ "ts-jest": "^29.4.5",
59
59
  "typescript": "^5.8.3",
60
60
  "typescript-eslint": "^8.38.0"
61
61
  },