Skip to content

Commit 8b8a2d8

Browse files
committed
removed setSaltLenght
addes setSaltDifficulty
1 parent 9ce9a25 commit 8b8a2d8

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ await c.decryptText(b64, pass);
9191
// runtime tweaks
9292
c.setDifficulty("high");
9393
c.setVersion(2); // choose another registered format
94-
c.setSaltLength(32);
94+
c.setSaltDifficulty("low");
9595

9696
// helpers
9797
Cryptit.isEncrypted(blobOrB64); // ↦ boolean
@@ -131,7 +131,7 @@ cat movie.enc | cryptit decode
131131
| ------------------------- | ------- | -------------------- |
132132
| `-p, --pass <pw>` | prompt | passphrase |
133133
| `-d, --difficulty <l>` | middle | Argon2 preset |
134-
| `-s, --salt-strength <l>` | high | 8 B vs 16 B salt |
134+
| `-s, --salt-strength <l>` | high | 12 B vs 16 B salt |
135135
| `-c, --chunk-size <n>` | 524 288 | plaintext block size |
136136
| `-v, --verbose` |  0 … 4 | repeat to increase |
137137

packages/core/src/index.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ export interface CryptitOptions {
6565
verbose? : Verbosity;
6666
/** Optional custom logger callback (receives formatted messages) */
6767
logger? : (msg: string) => void;
68-
/** Override salt length in bytes (advanced use) */
69-
saltLength? : number;
7068
}
7169

7270
/**
@@ -82,7 +80,6 @@ export class Cryptit {
8280

8381
private difficulty : Difficulty;
8482
private saltStrength : SaltStrength;
85-
private customSaltLen: number | null;
8683

8784
private readonly engines = new Map<number, Engine>();
8885

@@ -106,7 +103,6 @@ export class Cryptit {
106103

107104
this.difficulty = opt.difficulty ?? 'middle';
108105
this.saltStrength = opt.saltStrength ?? 'high';
109-
this.customSaltLen = opt.saltLength ?? null;
110106

111107
this.log = createLogger(opt.verbose ?? 0, opt.logger);
112108
}
@@ -174,10 +170,10 @@ export class Cryptit {
174170
* Override salt length (in bytes) for new operations (advanced use).
175171
* @param len - Custom salt length in bytes
176172
*/
177-
setSaltLength(len: number): void { this.customSaltLen = len; }
173+
setSaltDifficulty(d: SaltStrength): void { this.saltStrength = d; }
178174
/** Get the effective salt length for the current strength. */
179-
getSaltLength(): number {
180-
return this.customSaltLen ?? this.v.saltLengths[this.saltStrength];
175+
getSaltDifficulty(): SaltStrength {
176+
return this.saltStrength;
181177
}
182178

183179
/**
@@ -456,7 +452,7 @@ export class Cryptit {
456452

457453
/** Generate a secure random salt according to configured length. */
458454
private genSalt(): Uint8Array {
459-
const len = this.customSaltLen ?? this.v.saltLengths[this.saltStrength];
455+
const len = this.v.saltLengths[this.saltStrength];
460456
return this.provider.getRandomValues(new Uint8Array(len));
461457
}
462458

0 commit comments

Comments
 (0)