Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Error between android and ios decryption #17

Open

Description

@Senemix29

I am using RNCRyptorNative(version 0.0.9) at my android app, which have an iOS(swift) version too.
I have a chat which all messages sended are encrypted before save on my database.

When i send messages using android, encrypted by RNCryptorNative, i can't decrypt them on iOS, that uses RNCryptor(https://github.com/RNCryptor/RNCryptor, version 5.0.1) and always get this error:

  • Error decoding text: The operation couldn’t be completed. (RNCryptor.RNCryptor.Error error 2.)

The uncanny problem is that on Android, using your lib, i can decrypt every message that came from an iOS or Android.
On Android i am using the default implementation:


private static String encryptMessage(String message, String password) {
byte[] encryptedMessage = rncryptor.encrypt(message, password);
return new String(encryptedMessage);
}


private static String decryptMessage(String encryptedMessage, String password) {
return rncryptor.decrypt(encryptedMessage, password);
}


This is the following iOS code that are trying to decode android messages without success:


// Encryption
func EncryptText(myPassword: String, string: String) -> String {
let data = string.data(using: String.Encoding.utf8)
let encryptedData = RNCryptor.encrypt(data: data!, withPassword: myPassword)
return encryptedData.base64EncodedString(options: NSData.Base64EncodingOptions.init(rawValue: 0))
}


// Decryption
func DecryptText(chatRoomID: String, string: String) -> String {
let decryptor = RNCryptor.Decryptor(password: chatRoomID)
let encryptedData = NSData(base64Encoded: string, options:
NSData.Base64DecodingOptions(rawValue: 0))
var message: NSString = ""
do {
let decryptedData = try decryptor.decrypt(data: encryptedData! as Data)
message = NSString(data: decryptedData, encoding: String.Encoding.utf8.rawValue)!
} catch {
print("Error decoding text: (error)")
}
return message as String
}


I came with this issue here, because when i use JNCryptor on Android, iOS can decrypt my messages without any problem. I choose to use RNCryptorNative because of the huge performance gain.
Can you guys help me with that to try figure out whats happening?
Thanks and congrats for the lib!

Activity

  1. giolegaspijr commented on Aug 9, 2018

    @giolegaspijr

    Hello @Senemix29 , Were you able to solve this issue? thanks!

  2. Senemix29 commented on Aug 25, 2018

    @Senemix29
    Author

    @giolegaspijr i given up on this lib and move foward to another solutions without encryption =/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions