Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
react-native-quick-crypto
Advanced tools
A fast implementation of Node's `crypto` module written in C/C++ JSI
A fast implementation of Node's crypto
module.
Unlike any other current JS-based polyfills, react-native-quick-crypto is written in C/C++ JSI and provides much greater performance - especially on mobile devices. QuickCrypto can be used as a drop-in replacement for your Web3/Crypto apps to speed up common cryptography functions.
For example, creating a Wallet using ethers.js uses complex algorithms to generate a private-key/mnemonic-phrase pair:
const start = performance.now()
const wallet = ethers.Wallet.createRandom()
const end = performance.now()
console.log(`Creating a Wallet took ${end - start} ms.`)
Without react-native-quick-crypto 🐢:
Creating a Wallet took 16862 ms
With react-native-quick-crypto ⚡️:
Creating a Wallet took 289 ms
yarn add react-native-quick-crypto
yarn add react-native-quick-base64
cd ios && pod install
expo install react-native-quick-crypto
expo install react-native-quick-base64
expo prebuild
crypto-browserify
If you are using a library that depends on crypto
, instead of polyfilling it with crypto-browserify
(or react-native-crypto
) you can use react-native-quick-crypto
for a fully native implementation. This way you can get much faster crypto operations with just a single-line change!
In your babel.config.js
, add a module resolver to replace crypto
with react-native-quick-crypto
:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
+ [
+ 'module-resolver',
+ {
+ alias: {
+ 'crypto': 'react-native-quick-crypto',
+ 'stream': 'stream-browserify',
+ 'buffer': '@craftzdog/react-native-buffer',
+ },
+ },
+ ],
...
],
};
Then restart your bundler using yarn start --reset-cache
.
Now, all imports for crypto
will be resolved as react-native-quick-crypto
instead.
💡 Since react-native-quick-crypto depends on
stream
andbuffer
, we can resolve those tostream-browserify
and @craftzdog'sreact-native-buffer
(which is faster thanbuffer
because it uses JSI for base64 encoding and decoding).
For example, to hash a string with SHA256 you can do the following:
import Crypto from 'react-native-quick-crypto'
const hashed = Crypto.createHash('sha256')
.update('Damn, Margelo writes hella good software!')
.digest('hex')
As the library uses JSI for synchronous native methods access, remote debugging (e.g. with Chrome) is no longer possible. Instead, you should use Flipper.
react-native-quick-crypto was built at Margelo, an elite app development agency. For enterprise support or other business inquiries, contact us at hello@margelo.io!
See the contributing guide to learn how to contribute to the repository and the development workflow.
FAQs
A fast implementation of Node's `crypto` module written in C/C++ JSI
The npm package react-native-quick-crypto receives a total of 16,425 weekly downloads. As such, react-native-quick-crypto popularity was classified as popular.
We found that react-native-quick-crypto demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.