Skip to content

Commit 7b3c628

Browse files
committed
Update README for PBKDF2
1 parent 7fbb640 commit 7b3c628

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,21 @@ const salt = RNSimpleCrypto.utils.randomBytes(8);
182182
const iterations = 4096;
183183
const keyInBytes = 32;
184184
const hash = "SHA1";
185-
const passwordKey = await Pbkdf2.hash(
185+
const passwordKey = await RNSimpleCrypto.PBKDF2.hash(
186+
password,
187+
salt,
188+
iterations,
189+
keyInBytes,
190+
hash
191+
);
192+
console.log("PBKDF2 passwordKey", passwordKey);
193+
194+
const password = messageArrayBuffer;
195+
const salt = RNSimpleCrypto.utils.randomBytes(8);
196+
const iterations = 10000;
197+
const keyInBytes = 32;
198+
const hash = "SHA256";
199+
const passwordKey = await RNSimpleCrypto.PBKDF2.hash(
186200
password,
187201
salt,
188202
iterations,

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ const PBKDF2 = {
123123
saltToHash = convertUtf8ToArrayBuffer(salt);
124124
}
125125

126-
const hashHex = await NativeModules.Pbkdf2.hash(
126+
const digest = await NativeModules.Pbkdf2.hash(
127127
convertArrayBufferToBase64(passwordToHash),
128128
convertArrayBufferToBase64(saltToHash),
129129
iterations,
130130
keyLength,
131131
algorithm
132132
);
133133

134-
return convertBase64ToArrayBuffer(hashHex);
134+
return convertBase64ToArrayBuffer(digest);
135135
}
136136
};
137137

0 commit comments

Comments
 (0)