Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ example/ios/tmp.xcconfig
src/type.ts
cpp/crypto.cpp
android/src/main/java/com/reactnativekeysjsi/PrivateKey.java


.pnp*
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"react-native-builder-bob": "^0.21.3",
"release-it": "^15.0.0",
"turbo": "^1.10.7",
"typescript": "^5.0.2"
"typescript": "^5.8.3"
},
"resolutions": {
"@types/react": "17.0.21"
Expand Down Expand Up @@ -181,9 +181,10 @@
]
},
"dependencies": {
"crypto-js": "^4.2.0",
"fs-extra": "^11.1.1",
"normalize-path": "^3.0.0",
"react-native-nitro-modules": "^0.26.3",
"react-native-quick-crypto": "^0.7.15",
"walk-sync": "^3.0.0",
"xml2js": "^0.6.2"
},
Expand Down
17 changes: 7 additions & 10 deletions src/util/common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require('fs-extra');
const path = require('path');
const CryptoJS = require('crypto-js');
const crypto = require('crypto')
const QuickCrypto = require('react-native-quick-crypto');
const isExample = process.env.IS_EXAMPLE === 'TRUE';
const DEFAULT_FILE_NAME = 'keys.development.json';

Expand Down Expand Up @@ -213,18 +212,16 @@ module.exports.generatePassword = () => {
var length = 12,
charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
retVal = '';
const bytes = crypto.randomBytes(length);
const bytes = QuickCrypto.randomBytes(length);
for (var i = 0; i < length; ++i) {
retVal += charset.charAt(bytes[i] % charset.length);
}
return retVal;
};
module.exports.encrypt = (message, password, _iv) => {
const encrypted = CryptoJS.AES.encrypt(message, password, {
iv: _iv,
});

const base64Secret = encrypted.toString();

return base64Secret;
module.exports.encrypt = (message, password, _iv) => {
const cipher = QuickCrypto.createCipheriv('aes-256-ctr', password, _iv);
let encrypted = cipher.update(message, 'utf8', 'base64');
encrypted += cipher.final('base64');
return encrypted;
};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"esModuleInterop": true,
"verbatimModuleSyntax": false,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"jsx": "react-native",
"lib": [
"esnext"
],
Expand Down
Loading
Loading