Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hayr-hotoca/react-native-chacha20-poly1305
ChaCha20-Poly1305 encryption/decryption for Flutter. Native implementations make sure it has the fastest performance.
https://github.com/hayr-hotoca/react-native-chacha20-poly1305
256-bit aes android chacha20 chacha20-poly1305 chacha20poly1305 cipher cipher-algorithms cross-platform cryptography encryption encryption-algorithms ios javascript react react-native reactjs typescript
Last synced: 1 day ago
JSON representation
ChaCha20-Poly1305 encryption/decryption for Flutter. Native implementations make sure it has the fastest performance.
- Host: GitHub
- URL: https://github.com/hayr-hotoca/react-native-chacha20-poly1305
- Owner: hayr-hotoca
- License: mit
- Created: 2023-08-17T08:55:04.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-17T17:39:16.000Z (10 months ago)
- Last Synced: 2024-11-08T06:19:44.176Z (9 days ago)
- Topics: 256-bit, aes, android, chacha20, chacha20-poly1305, chacha20poly1305, cipher, cipher-algorithms, cross-platform, cryptography, encryption, encryption-algorithms, ios, javascript, react, react-native, reactjs, typescript
- Language: Java
- Homepage: https://1limx.com
- Size: 438 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# react-native-chacha20-poly1305
ChaCha20-Poly1305 encryption/decryption for React Native.\
Encrypt binary and text-like data with ease.\
Native implementations make sure it has the fastest performance.# Requirements
iOS >= 13.0\
Android >= 26## Installation
```sh
npm i --save react-native-chacha20-poly1305
```## Usage
```js
import { decrypt, encrypt } from 'react-native-chacha20-poly1305';
import { generateSymmetricKey } from 'react-native-key-generator';(async () => {
const key = await generateSymmetricKey({ size: 256, outputEncoding: "base64" });
// new unique key will be generated every time generateSymmetricKey is run
// xyD2rJTETEBCBA538mAvCVG0AdF1lOm0kR7z1eRLdwQ=
// hex encoding of key is c720f6ac94c44c4042040e77f2602f0951b401d17594e9b4911ef3d5e44b7704const encrypted = await encrypt({
plainText: JSON.stringify({ x: 1, y: 2 }),
key: "c720f6ac94c44c4042040e77f2602f0951b401d17594e9b4911ef3d5e44b7704",
keyEncoding: "hex",
outputEncoding: "base64"
});
console.log(encrypted);
// Data in this object will be unique every time encrypt function is run
// {
// "encrypted": "997U4wbic8FbEFeeEA==",
// "nonce": "ZGfMRlCFSGZMpUj2",
// "tag": "6MHP+gQh2hCFF6MFRCNeRQ=="
// }// nonce: (or "initialization vector", "IV", "salt") is a unique non-secret sequence of data required by most cipher (encryption) algorithms, making the ciphertext (encrypted data) unique despite the same key
// tag: authentication tag or MAC (message authentication code), the algorithm uses it to verify whether or not the ciphertext (encrypted data) and/or associated data have been modified.
const decrypted = await decrypt({
encrypted: "997U4wbic8FbEFeeEA==",
key: "xyD2rJTETEBCBA538mAvCVG0AdF1lOm0kR7z1eRLdwQ=",
nonce: "ZGfMRlCFSGZMpUj2",
tag: "6MHP+gQh2hCFF6MFRCNeRQ==",
inputEncoding: "base64",
});
console.log(decrypted); // '{"x":1,"y":2}'
})();
```## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## Author
Hayr Hotoca | [@1limxapp](https://twitter.com/1limxapp)\
This package is used in my cross-platform app called [1LimX](https://1limx.com/)
## LicenseMIT