Skip to content

Commit

Permalink
Add namespace to typedef and bump ver to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tectiv3 committed Dec 3, 2021
1 parent 5bf0bae commit 6e80401
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
3 changes: 1 addition & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:4.0.1'
}
}
}
Expand Down Expand Up @@ -65,6 +65,5 @@ dependencies {
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.madgag.spongycastle:core:1.58.0.0'
implementation 'com.madgag.spongycastle:prov:1.54.0.0'
implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
implementation 'com.madgag.spongycastle:pg:1.54.0.0'
}
4 changes: 2 additions & 2 deletions android/src/main/java/com/tectiv3/aes/RCTAes.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public String getName() {
}

@ReactMethod
public void encrypt(String data, String key, String iv, Promise promise) {
public void encrypt(String data, String key, String iv, String algorithm, Promise promise) {
try {
String result = encrypt(data, key, iv);
promise.resolve(result);
Expand All @@ -65,7 +65,7 @@ public void encrypt(String data, String key, String iv, Promise promise) {
}

@ReactMethod
public void decrypt(String data, String pwd, String iv, Promise promise) {
public void decrypt(String data, String pwd, String iv, String algorithm, Promise promise) {
try {
String strs = decrypt(data, pwd, iv);
promise.resolve(strs);
Expand Down
22 changes: 13 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
declare module 'react-native-aes-crypto' {
function pbkdf2(password: string, salt: string, cost: number, length: number): Promise<string>
function encrypt(text: string, key: string, iv: string, algorithm: string): Promise<string>
function decrypt(ciphertext: string, key: string, iv: string): Promise<string>
function hmac256(ciphertext: string, key: string): Promise<string>
function hmac512(ciphertext: string, key: string): Promise<string>
function randomKey(length: number): Promise<string>
function sha1(text: string): Promise<string>
function sha256(text: string): Promise<string>
function sha512(text: string): Promise<string>
namespace Aes {
type Algorithms = 'aes-128-cbc' | 'aes-192-cbc' | 'aes-256-cbc'

function pbkdf2(password: string, salt: string, cost: number, length: number): Promise<string>
function encrypt(text: string, key: string, iv: string, algorithm: Algorithms): Promise<string>
function decrypt(ciphertext: string, key: string, iv: string, algorithm: Algorithms): Promise<string>
function hmac256(ciphertext: string, key: string): Promise<string>
function hmac512(ciphertext: string, key: string): Promise<string>
function randomKey(length: number): Promise<string>
function sha1(text: string): Promise<string>
function sha256(text: string): Promise<string>
function sha512(text: string): Promise<string>
}
}
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
import { NativeModules } from 'react-native';
'use strict'
import { NativeModules } from 'react-native'

export default NativeModules.Aes;
export default NativeModules.Aes
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-aes-crypto",
"version": "1.3.10",
"version": "2.0.0",
"description": "AES crypto native module for react-native",
"main": "index.js",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion react-native-aes.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = 'react-native-aes'
s.version = '1.3.10'
s.version = '2.0.0'
s.summary = 'Native module for AES encryption'
s.author = "tectiv3"
s.license = 'MIT'
Expand Down

0 comments on commit 6e80401

Please sign in to comment.