https://github.com/poowf/react-native-argon2
https://github.com/poowf/react-native-argon2
argon2 crypto encryption hacktoberfest hashing password react-native
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/poowf/react-native-argon2
- Owner: poowf
- License: mit
- Created: 2020-04-28T19:06:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T14:21:25.000Z (over 3 years ago)
- Last Synced: 2025-01-15T00:36:28.934Z (over 1 year ago)
- Topics: argon2, crypto, encryption, hacktoberfest, hashing, password, react-native
- Language: Java
- Homepage:
- Size: 121 KB
- Stars: 5
- Watchers: 4
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-argon2
React Native Wrapper around native Argon2 implementations:
iOS: [CatCrypto](//github.com/ImKcat/CatCrypto)
Android: [argon2kt](//github.com/lambdapioneer/argon2kt)
## Getting started
```bash
npm install react-native-argon2 --save
```
Compatibility Table
| React Native Version | Package Version |
|----------------------|-----------------|
| 0.60 - 0.63.2 | ~0.1.0 |
| 0.63.3 | ^1.0.0 |
## Usage
```javascript
import argon2 from 'react-native-argon2';
const password = 'password';
const salt = '1234567891011121314151617181920212223242526272829303132333435363';
const result = await argon2(password, salt, {});
const { rawHash, encodedHash } = result;
// rawHash: 031d6c82ddede1200f4794605052745dd562bd4db358e23dac1b11c052eff8d9
// encodedHash: $argon2id$v=19$m=32768,t=2,p=1$MTIzNDU2Nzg5MTAxMTEyMTMxNDE1MTYxNzE4MTkyMDIxMjIyMzI0MjUyNjI3MjgyOTMwMzEzMjMzMzQzNTM2Mw$Ax1sgt3t4SAPR5RgUFJ0XdVivU2zWOI9rBsRwFLv+Nk
```
### Input
The package takes in the following variables:
| Parameter | Type |
|---------------------|---------|
| password | string |
| salt | string |
| config | object |
| config.iterations | integer |
| config.memory | integer |
| config.parallelism | integer |
| config.hashLength | integer |
| config.mode | string |
You are not required to configure the third parameter which is the `config` object, however you do have to provide an empty object to it if you are not changing any of the values. You can set config values with the following example:
```javascript
const result = await argon2(
password,
salt,
{
iterations: 5,
memory: 16 * 1024,
parallelism: 2,
hashLength: 20,
mode: 'argon2i'
}
);
```
### Output
`rawHash` is the hexadecimal representation
`encodedHash` is the string representation