@@ -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