npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-libsodium

v1.4.0

Published

React Native bindings to Libsodium matching the libsodium-wrappers API

Downloads

3,269

Readme

react-native-libsodium

React Native bindings to Libsodium matching the libsodium-wrappers package API

Supported Platforms:

  • iOS
  • Android
  • Web

Currently only a subset of the libsodium-wrappers exposed functionality is implemented. For missing functionality we welcome pull-requests or you can sponsor the development. Get in touch with us at [email protected].

Installation Expo (dev-client)

This package support the Expo plugin system and can be used together with the Expo dev-client.

npm install react-native-libsodium

Extend app.config.js with the following plugins entry:

export default {
  expo: {
    …
    plugins: [["react-native-libsodium", {}]],
  }
}

Installation React Native

npm install react-native-libsodium
cd ios && pod install

Usage

Hint: see the example app in the repository regarding how to use the functions

import {
  crypto_auth,
  crypto_auth_verify,
  crypto_auth_BYTES,
  crypto_auth_KEYBYTES,
  crypto_auth_keygen,
  crypto_aead_xchacha20poly1305_ietf_decrypt,
  crypto_aead_xchacha20poly1305_ietf_encrypt,
  crypto_aead_xchacha20poly1305_ietf_KEYBYTES,
  crypto_aead_xchacha20poly1305_ietf_NPUBBYTES,
  crypto_aead_xchacha20poly1305_ietf_keygen,
  crypto_box_easy,
  crypto_box_keypair,
  crypto_box_seed_keypair,
  crypto_box_open_easy,
  crypto_box_PUBLICKEYBYTES,
  crypto_box_SECRETKEYBYTES,
  crypto_box_SEEDBYTES,
  crypto_box_seal,
  crypto_box_seal_open,
  crypto_kdf_CONTEXTBYTES,
  crypto_kdf_derive_from_key,
  crypto_kdf_KEYBYTES,
  crypto_kdf_keygen,
  crypto_pwhash, // only with loadSumoVersion with react-native-web
  crypto_pwhash_ALG_DEFAULT, // only with loadSumoVersion with react-native-web
  crypto_pwhash_MEMLIMIT_INTERACTIVE, // only with loadSumoVersion with react-native-web
  crypto_pwhash_OPSLIMIT_INTERACTIVE, // only with loadSumoVersion with react-native-web
  crypto_pwhash_SALTBYTES, // only with loadSumoVersion with react-native-web
  crypto_generichash,
  crypto_generichash_BYTES,
  crypto_generichash_BYTES_MIN,
  crypto_generichash_BYTES_MAX,
  crypto_generichash_KEYBYTES,
  crypto_generichash_KEYBYTES_MIN,
  crypto_generichash_KEYBYTES_MAX,
  crypto_secretbox_easy,
  crypto_secretbox_KEYBYTES,
  crypto_secretbox_keygen,
  crypto_secretbox_NONCEBYTES,
  crypto_secretbox_open_easy,
  crypto_sign_detached,
  crypto_sign_keypair,
  crypto_sign_SEEDBYTES,
  crypto_sign_verify_detached,
  from_base64,
  randombytes_buf,
  randombytes_uniform,
  to_base64,
  to_hex,
  to_string,
  ready, // only needed for react-native-web
  loadSumoVersion, // only relevant for react-native-web
  _unstable_crypto_kdf_hkdf_sha256_BYTES_MAX, // has no counterpart in libsodium-wrappers yet
  _unstable_crypto_kdf_hkdf_sha256_BYTES_MIN, // has no counterpart in libsodium-wrappers yet
  _unstable_crypto_kdf_hkdf_sha256_KEYBYTES, // has no counterpart in libsodium-wrappers yet
  _unstable_crypto_kdf_hkdf_sha256_extract, // has no counterpart in libsodium-wrappers yet
  _unstable_crypto_kdf_hkdf_sha256_expand, // has no counterpart in libsodium-wrappers yet
} from 'react-native-libsodium';

// ...

React Native Web

For the web platform the constants and functions from the libsodium-wrappers package is exposed. This also means you need to wait for the ready Promise to be resolved before using any constant or function.

Certain constants and functions e.g. crypto_pwhash are only available in the libsodium-wrappers-sumo package. To load this package instead for web you can call loadSumoVersion right after importing the package.

import { loadSumoVersion, ready } from 'react-native-libsodium';

loadSumoVersion();

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

The to_string function and base64_variants enum was copied from the libsodium.js project and you can find the license at LICENSE_libsodiumjs.


Made with create-react-native-library

Acknowledgment

Thanks to Donus for freeing up the react-native-libsodium package name on npm.