Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
react-native-aes-crypto
Advanced tools
AES encryption/decryption for react-native
npm install --save react-native-aes-crypto
or
yarn add react-native-aes-crypto
cd ios
pod install
Run react-native link react-native-aes-crypto
after which you should be able to use this library on iOS.
android/settings.gradle
...
include ':react-native-aes-crypto'
project(':react-native-aes-crypto').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-aes-crypto/android')
android/app/build.gradle
...
dependencies {
...
compile project(':react-native-aes-crypto')
}
......
import com.tectiv3.aes.RCTAesPackage;
......
@Override
protected List<ReactPackage> getPackages() {
......
new RCTAesPackage(),
// or
// packages.add(new RCTAesPackage());
......
}
import { NativeModules, Platform } from 'react-native'
import Aes from 'react-native-aes-crypto'
const generateKey = (password, salt, cost, length) => Aes.pbkdf2(password, salt, cost, length, 'sha256')
const encryptData = (text, key) => {
return Aes.randomKey(16).then(iv => {
return Aes.encrypt(text, key, iv, 'aes-256-cbc').then(cipher => ({
cipher,
iv,
}))
})
}
const decryptData = (encryptedData, key) => Aes.decrypt(encryptedData.cipher, key, encryptedData.iv, 'aes-256-cbc')
try {
generateKey('Arnold', 'salt', 5000, 256).then(key => {
console.log('Key:', key)
encryptData('These violent delights have violent ends', key)
.then(({ cipher, iv }) => {
console.log('Encrypted:', cipher)
decryptData({ cipher, iv }, key)
.then(text => {
console.log('Decrypted:', text)
})
.catch(error => {
console.log(error)
})
Aes.hmac256(cipher, key).then(hash => {
console.log('HMAC', hash)
})
})
.catch(error => {
console.log(error)
})
})
} catch (e) {
console.error(e)
}
async function asyncDecrypt(cipher, key, iv) {
try {
var text = await decryptData({ cipher, iv }, key)
console.log(text)
return text
} catch (e) {
console.error(e)
}
}
encrypt(text, key, iv, algorithm)
decrypt(base64, key, iv, algorithm)
pbkdf2(text, salt, cost, length, algorithm)
hmac256(cipher, key)
hmac512(cipher, key)
sha1(text)
sha256(text)
sha512(text)
randomUuid()
randomKey(length)
FAQs
AES crypto native module for react-native
The npm package react-native-aes-crypto receives a total of 9,257 weekly downloads. As such, react-native-aes-crypto popularity was classified as popular.
We found that react-native-aes-crypto demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.