
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
react-native-hash
Advanced tools
$ npm install react-native-hash --save
| Criteria | Release Version |
|---|---|
Android API < 16 | unsupported |
16 <= Android API < 21 | 1.x |
Gradle >= 7 | >= 2.0.1 |
HashAlgorithms : Record<string, string>;
HmacAlgorithms : Record<string, string>;
Events : Record<string, string>;
import { CONSTANTS } from 'react-native-hash';
const hashAlgorithm = CONSTANTS.HashAlgorithms.sha256;
const hmacAlgorithm = CONSTANTS.HmacAlgorithms.HmacSHA512;
const EventName = CONSTANTS.Events.onBatchReccieved;
Native hashing is only implemented on Android, however, until I get around writing native modules for other platforms ( or if some kind soul makes a PR), you can use JSHash and JSHmac:
NOTE
if you are using expo, JSHash and JSHmac should work out of the box, native implementations however, will require you to eject the project.
"MD2" | "MD5"| "SHA-1"| "SHA-224" | "SHA-256" | "SHA-384" | "SHA-512"| "keccak"
"HmacMD5" | "HmacSHA1" | "HmacSHA224" | "HmacSHA256" | "HmacSHA384" | "HmacSHA512"
JSHash(message: string, algorithm: string):Promise<string>;
JSHmac(message: string, secret: string, algorithm: string): Promise<string>;
import { JSHash, JSHmac, CONSTANTS } from "react-native-hash";
JSHash("message", CONSTANTS.HashAlgorithms.sha256)
.then(hash => console.log(hash))
.catch(e => console.log(e));
JSHmac("message", "SecretKey", CONSTANTS.HmacAlgorithms.HmacSHA256)
.then(hash => console.log(hash))
.catch(e => console.log(e));
check out the example for more information.
"md2" | "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512"
"HmacMD5" | "HmacSHA1" | "HmacSHA224" | "HmacSHA256" | "HmacSHA384" | "HmacSHA512" | "PBEwithHmacSHA"
"PBEwithHmacSHA1" | "PBEwithHmacSHA224" | "PBEwithHmacSHA256" | "PBEwithHmacSHA384" | "PBEwithHmacSHA512"
hashFile(uri: string, algorithm: string):Promise<string>;
hashFilesForFolder(uri: string, algorithm: string, minFileSize: number, maxFileSize: number, extensionFilter: string, batchSize: number, delay: number ): Promise<{FilesCount:number, isFinalBatch: bool, batchNumber: number, results: Record<string, string>}>;
"" to the hashFilesForFolder as extensionFilter if you dont want to filter the results."press to hash Folder with events" and "press to hash Folder" in the example app for more detailshashFilesForFolders(uri: string, algorithm: string, minFileSize: number, maxFileSize: number, extensionFilter: string, batchSize: number, delay: number ): Promise<{FilesCount:number, isFinalBatch: bool, batchNumber: number, results: Record<string, string>}>;
hashFilesForFolder, but reccieves an String array as first argument.hashUrl(url: string, HTTPMethod: string, headers: Record<string, string>, algorithm: string):Promise<string>;
hashString(message: string, algorithm: string):Promise<string>;
generateHmac(message: string, key: string, algorithm: string):Promise<string>;
import RnHash, { CONSTANTS } from "react-native-hash";
RnHash.hashFile("uri", CONSTANTS.HashAlgorithms.sha256)
.then(hash => console.log(hash))
.catch(e => console.log(e));
RNHash.hashFilesForFolders(
["uri", "anotherUri"],
CONSTANTS.HashAlgorithms.sha256,
0,
1048576,
".mp3",
-1,
0
)
.then(b => setFolderString(JSON.stringify(b)))
.catch(er => console.log(er));
RNHash.hashFilesForFolder(
"uri",
CONSTANTS.HashAlgorithms.sha256,
0,
1048576,
".mp3",
-1,
0
)
.then(b => setFolderString(JSON.stringify(b)))
.catch(er => console.log(er));
RnHash.hashUrl(
"url",
"HTTPMethod",
{ "Content-type": "application/json" },
CONSTANTS.HashAlgorithms.sha256
)
.then(hash => console.log(hash))
.catch(e => console.log(e));
RnHash.hashString("message", CONSTANTS.HashAlgorithms.sha256)
.then(hash => console.log(hash))
.catch(e => console.log(e));
RNHash.generateHmac("message", "secretKey", CONSTANTS.HmacAlgorithms.HmacSHA512)
.then(HMAC => console.log(HMAC))
.catch(er => console.log(er));
check out the example for more information.
| iOS | Android | windows | |
|---|---|---|---|
| hash local files | :x: | :heavy_check_mark: | :x: |
| hash network assets | :x: | :heavy_check_mark: | :x: |
| hash network responses | :x: | :heavy_check_mark: | :x: |
| hash bundle assets | :x: | :x: | :x: |
| hash strings | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| HMAC | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
JSHash and JSHMac functions use some Open Source code snippets. You can find the source code of their open source projects along with license information below. We acknowledge and are grateful to these developers for their contributions to open source.
Project: crypto-es https://github.com/entronad/crypto-es
License (MIT) https://github.com/entronad/crypto-es/blob/master/LICENSE
FAQs
A hashing library for react-native
The npm package react-native-hash receives a total of 2,305 weekly downloads. As such, react-native-hash popularity was classified as popular.
We found that react-native-hash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.