From 1b95d4d34661bbedc33e824377fbca567fdc4a95 Mon Sep 17 00:00:00 2001 From: hayr-hotoca Date: Mon, 14 Aug 2023 17:21:22 +0700 Subject: [PATCH] feat 0.1.1: change aes to chacha20 on android --- README.md | 2 +- android/src/main/java/com/keygenerator/KeyGeneratorModule.kt | 2 +- ios/KeyGenerator.swift | 2 +- package.json | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 61d5037..77e30ff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # react-native-key-generator -Secure unique key generator for React Native +Secure unique 128, 192, 256 bit key generator for React Native # Requirements iOS >= 13.0\ diff --git a/android/src/main/java/com/keygenerator/KeyGeneratorModule.kt b/android/src/main/java/com/keygenerator/KeyGeneratorModule.kt index 8b88f0d..781550d 100644 --- a/android/src/main/java/com/keygenerator/KeyGeneratorModule.kt +++ b/android/src/main/java/com/keygenerator/KeyGeneratorModule.kt @@ -28,8 +28,8 @@ class KeyGeneratorModule(reactContext: ReactApplicationContext) : if (outputEncoding != "base64" && outputEncoding != "hex") { return promise.reject("Output encoding error", "Output encoding should be in 'base64' or 'hex'", null) } + val keygen = KeyGenerator.getInstance("ChaCha20") - val keygen = KeyGenerator.getInstance("AES") keygen.init(size) val key: SecretKey = keygen.generateKey() val encodedKey = if (outputEncoding == "base64") diff --git a/ios/KeyGenerator.swift b/ios/KeyGenerator.swift index 8f01496..f04d747 100644 --- a/ios/KeyGenerator.swift +++ b/ios/KeyGenerator.swift @@ -23,7 +23,7 @@ class KeyGenerator: NSObject { @objc(generateSymmetricKey:withOutputEncoding:withResolver:withRejecter:) func generateSymmetricKey(size: Int, outputEncoding: String, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void { if (outputEncoding != "base64" && outputEncoding != "hex") { - reject("Output encoding error", "Output encoding should be in 'base64' or 'hex'", nil) + return reject("Output encoding error", "Output encoding should be in 'base64' or 'hex'", nil) } var newKey = SymmetricKey.init(size: SymmetricKeySize.bits256) diff --git a/package.json b/package.json index 288ef2f..8452501 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-native-key-generator", - "version": "0.1.0", - "description": "Secure unique key generator for React Native", + "version": "0.1.1", + "description": "Secure unique 128, 192, 256 bit key generator for React Native", "main": "lib/commonjs/index", "module": "lib/module/index", "types": "lib/typescript/index.d.ts",