Skip to content

Commit ac5e581

Browse files
committed
SHA: Add examples with buffers to README
1 parent be842a5 commit ac5e581

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ All methods are asynchronous and return promises (except for convert utils)
8383
- decrypt(cipherText: ArrayBuffer, key: ArrayBuffer, iv: ArrayBuffer)
8484
- SHA
8585
- sha1(text: string)
86+
- sha1(text: ArrayBuffer)
8687
- sha256(text: string)
88+
- sha256(text: ArrayBuffer)
8789
- sha512(text: string)
90+
- sha512(text: ArrayBuffer)
8891
- HMAC
8992
- hmac256(text: ArrayBuffer, key: ArrayBuffer)
9093
- PBKDF2
@@ -163,6 +166,13 @@ console.log("SHA256 hash", sha256Hash);
163166
const sha512Hash = await RNSimpleCrypto.SHA.sha1("test");
164167
console.log("SHA512 hash", sha512Hash);
165168

169+
const dataToHash = await RNSimpleCrypto.utils.randomBytes(64);
170+
const sha1ArrayBuffer = await RNSimpleCrypto.SHA.sha1(dataToHash);
171+
console.log('SHA256 hash bytes', [...sha1ArrayBuffer]);
172+
173+
const sha256ArrayBuffer = await RNSimpleCrypto.SHA.sha256(dataToHash);
174+
console.log('SHA256 hash bytes', [...sha256ArrayBuffer]);
175+
166176
// -- PBKDF2 ---------------------------------------------------------- //
167177

168178
const password = "secret password";

0 commit comments

Comments
 (0)