Skip to content

Commit afd188f

Browse files
author
pioner921227
committed
fix
1 parent bc1e140 commit afd188f

File tree

1 file changed

+76
-38
lines changed

1 file changed

+76
-38
lines changed

README.md

Lines changed: 76 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,104 @@
1-
# 🚀 react-native-config-jsi
1+
# react-native-xxhash
22

3-
**Fast JSI-based React Native library to access `.env` variables natively with C++ performance.**
3+
A React Native library for hashing strings using the fast and deterministic xxHash algorithm, written in C++ with JSI for high performance. This library provides support for both 64-bit and 128-bit hashing.
44

5-
---
65

7-
## 📦 Install
6+
## Features
87

9-
```sh
10-
npm install react-native-config-jsi # or yarn add react-native-config-jsi
11-
```
8+
- **High Performance**: xxHash is one of the fastest non-cryptographic hash functions.
9+
- **Deterministic Hashing**: Ensures consistent results for the same input.
10+
- **128-bit and 64-bit Support**: Choose between 128-bit and 64-bit hash outputs based on your use case.
11+
- **Cross-Platform**: Supports both iOS and Android in React Native projects.
1212

13-
---
13+
## Installation
1414

15-
## 🔧 Quick Setup
15+
To install the library, use either `npm` or `yarn`:
1616

17-
1. Create `.env` at project root:
18-
```env
19-
API_KEY=your_api_key
20-
APP_NAME=MyAwesomeApp
17+
```sh
18+
npm install react-native-xxhash
2119
```
2220

23-
2. **iOS:**
24-
```bash
25-
cd ios && pod install
26-
```
27-
Add to Xcode → Target → Build Phases → **+ New Run Script Phase**:
28-
```bash
29-
bash "${SRCROOT}/../node_modules/react-native-config-jsi/src/scripts/generate.sh"
21+
```sh
22+
yarn add react-native-xxhash
3023
```
3124

32-
3. **Android:**
33-
Add to bottom of `android/app/build.gradle`:
34-
```gradle
35-
apply from: project(':react-native-config-jsi').projectDir.getPath() + "/dotenv.gradle"
25+
## iOS
26+
```sh
27+
pod install
3628
```
3729

3830
---
3931

40-
## 🚀 Usage
32+
## Usage
4133

42-
```js
43-
import { RNConfig } from "react-native-config-jsi";
34+
Here’s how to use the `react-native-xxhash` library in your React Native project:
4435

45-
const apiKey = RNConfig.get("API_KEY");
46-
console.log("API_KEY:", apiKey);
36+
### Import the Functions
37+
```javascript
38+
import { hash128, hash64 } from 'react-native-xxhash';
4739
```
4840

49-
---
41+
### Hash a String (128-bit)
42+
This function generates a fast and deterministic 128-bit hash for a given string input.
43+
44+
```javascript
45+
const resultHash128 = hash128("hello world");
46+
console.log('128-bit hash:', resultHash128);
47+
// Output: A 128-bit hash string
48+
```
49+
50+
### Hash a String (64-bit)
51+
This function generates a fast and deterministic 64-bit hash for a given string input.
5052

51-
## ⚡ Highlights
53+
```javascript
54+
const resultHash64 = hash64("hello world");
55+
console.log('64-bit hash:', resultHash64);
56+
// Output: A 64-bit hash string
57+
```
5258

53-
- 🔥 Ultra-fast JSI native access
54-
- ⚙️ Built in C++
55-
- 🧩 Synchronous API
56-
- 🪶 No extra dependencies
59+
### Example Usage in a Component
60+
```javascript
61+
import React, { useEffect } from 'react';
62+
import { Text, View } from 'react-native';
63+
import { hash128, hash64 } from 'react-native-xxhash';
64+
65+
const App = () => {
66+
useEffect(() => {
67+
const hash128Result = hash128("react-native");
68+
const hash64Result = hash64("react-native");
69+
70+
console.log("128-bit hash:", hash128Result);
71+
console.log("64-bit hash:", hash64Result);
72+
}, []);
73+
74+
return (
75+
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
76+
<Text>Check your console for hash results!</Text>
77+
</View>
78+
);
79+
};
80+
81+
export default App;
82+
```
5783

5884
---
5985

60-
## 📜 License
86+
## API Reference
6187

62-
MIT
88+
### `hash128(input: string): string`
89+
- **Description**: Generates a 128-bit hash for the given string input.
90+
- **Parameters**:
91+
- `input` (string): The string to hash.
92+
- **Returns**: A 128-bit hash as a string.
93+
94+
### `hash64(input: string): string`
95+
- **Description**: Generates a 64-bit hash for the given string input.
96+
- **Parameters**:
97+
- `input` (string): The string to hash.
98+
- **Returns**: A 64-bit hash as a string.
6399

64100
---
65101

66-
🎉 **Enjoy using react-native-config-jsi!** 🚀
102+
## License
103+
104+
`react-native-xxhash` is released under the MIT License. See the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)