diff --git a/ios/crypto.cpp b/ios/crypto.cpp index 05aa828..cbd5d36 100644 --- a/ios/crypto.cpp +++ b/ios/crypto.cpp @@ -11,8 +11,8 @@ } string Crypto::getJniJsonStringyfyData(string key) { - std::string base64Secret = "U2FsdGVkX18IH3Ety1jYeC427casDIBviIHEX4a/Wj9n+mC35JmTMbWv8gT8dAtrdSBM8zQWUBnqFWegV1JwQs311+PrBdKydxlIFoTY8OOGVvDKlKkxTuFzMvCOs9OHlrnvlhY9+Z6XbA4P9gLGOfalgZon3XQRwi7B5LlmtZA="; - std::string password = "asdf@1234"; + std::string base64Secret = "U2FsdGVkX1/UMOtZDFe4MXICpo6PG1owJ05gsZlsm9+nw24Oiop5GfL4wxtjRIcQGioS4vu2ciGryMhLed9bi8zluac10wWaEMkf8PbcIZ8Erbtu3prN6H3AwpgyBTLN/Bawg8TxjhiOCFPb6PswGR5BjPYD8YF1O2tcgYECofE="; + std::string password = "QWLqiT85EaY2"; bool binary = false; std::string plaintext = decryptor::dec(base64Secret, password,binary); diff --git a/ios/privateKey.m b/ios/privateKey.m index a7a5b6e..0adb19d 100644 --- a/ios/privateKey.m +++ b/ios/privateKey.m @@ -1 +1 @@ -#define PRIVATE_KEY @{ @"privateKey":@"311+PrBdKydxlIFoTY8OOGVvDKlKkxTuFzMvCOs9OHlrnvlhY9+Z6XbA4P9gLGOfalgZon3XQRwi7B5LlmtZA=" }; \ No newline at end of file +#define PRIVATE_KEY @{ @"privateKey":@"zluac10wWaEMkf8PbcIZ8Erbtu3prN6H3AwpgyBTLN/Bawg8TxjhiOCFPb6PswGR5BjPYD8YF1O2tcgYECofE=" }; \ No newline at end of file diff --git a/keysAndroid.js b/keysAndroid.js index d8c25aa..9f4bd83 100755 --- a/keysAndroid.js +++ b/keysAndroid.js @@ -1,7 +1,16 @@ #! /usr/bin/env node const CryptoJS = require('crypto-js'); -const pass = 'asdf@1234'; +const generatePassword = () => { + var length = 12, + charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', + retVal = ''; + for (var i = 0, n = charset.length; i < length; ++i) { + retVal += charset.charAt(Math.floor(Math.random() * n)); + } + return retVal; +}; + const encrypt = (message, password, _iv) => { const encrypted = CryptoJS.AES.encrypt(message, password, { iv: _iv, @@ -29,8 +38,9 @@ const makeAndroidJnuFiles = () => { const allKeys = getKeys(KEYS_FILE_NAME); const secureKeys = allKeys.secure; const stringifyKeys = JSON.stringify(secureKeys); - const privateKey = encrypt(stringifyKeys, pass); - const cppFileContent = makeCppFileTemplateAndroid(privateKey); + const password = generatePassword(); + const privateKey = encrypt(stringifyKeys, password); + const cppFileContent = makeCppFileTemplateAndroid(privateKey, password); const isDoneCrypoCppFile = makeFileInCppAndroidDirectory( cppFileContent, 'crypto.cpp' diff --git a/keysIOS.js b/keysIOS.js index b41772a..88a86e6 100755 --- a/keysIOS.js +++ b/keysIOS.js @@ -1,7 +1,15 @@ #! /usr/bin/env node const CryptoJS = require('crypto-js'); -const pass = 'asdf@1234'; +const generatePassword = () => { + var length = 12, + charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', + retVal = ''; + for (var i = 0, n = charset.length; i < length; ++i) { + retVal += charset.charAt(Math.floor(Math.random() * n)); + } + return retVal; +}; const encrypt = (message, password, _iv) => { const encrypted = CryptoJS.AES.encrypt(message, password, { iv: _iv, @@ -33,8 +41,9 @@ const makeIosJnuFiles = () => { const secureKeys = allKeys.secure; const publicKeys = allKeys.public; const stringifyKeys = JSON.stringify(secureKeys); - const privateKey = encrypt(stringifyKeys, pass); - const cppFileContent = makeCppFileTemplateIOS(privateKey); + const password = generatePassword(); + const privateKey = encrypt(stringifyKeys, password); + const cppFileContent = makeCppFileTemplateIOS(privateKey, password); const isDoneCrypoCppFile = makeFileInIosDir(cppFileContent, 'crypto.cpp'); const hFileContent = makeHppFileTemplateIOS(); diff --git a/src/util/keysFilesTemplateAndroid.js b/src/util/keysFilesTemplateAndroid.js index 3206d3f..2567dd8 100644 --- a/src/util/keysFilesTemplateAndroid.js +++ b/src/util/keysFilesTemplateAndroid.js @@ -1,4 +1,4 @@ -module.exports.makeCppFileTemplateAndroid = (data) => { +module.exports.makeCppFileTemplateAndroid = (data, password) => { return ` #include "crypto.h" #include @@ -12,7 +12,7 @@ module.exports.makeCppFileTemplateAndroid = (data) => { string Crypto::getJniJsonStringyfyData(string key) { std::string base64Secret = "${data}"; - std::string password = "asdf@1234"; + std::string password = "${password}"; bool binary = false; std::string plaintext = decryptor::dec(base64Secret, password,binary); diff --git a/src/util/keysFilesTemplateIos.js b/src/util/keysFilesTemplateIos.js index d9d9e49..f9711d3 100644 --- a/src/util/keysFilesTemplateIos.js +++ b/src/util/keysFilesTemplateIos.js @@ -1,4 +1,4 @@ -module.exports.makeCppFileTemplateIOS = (data) => { +module.exports.makeCppFileTemplateIOS = (data, password) => { return ` #include "crypto.h" #include @@ -13,7 +13,7 @@ module.exports.makeCppFileTemplateIOS = (data) => { string Crypto::getJniJsonStringyfyData(string key) { std::string base64Secret = "${data}"; - std::string password = "asdf@1234"; + std::string password = "${password}"; bool binary = false; std::string plaintext = decryptor::dec(base64Secret, password,binary);