Android Question B4xCipher decryption on other platforms

Pxs

Member
Licensed User
Hello

I've been using b4xCipher to encrypt/decrypt strings in a text file before sharing it (with a secret static key) in my android app, with this very simple implementation:

B4X:
Sub EncryptString(text As String, password As String) As String
    Dim c As B4XCipher
    Dim e() As Byte
    e = c.Encrypt(text.GetBytes("utf8"), password)
    Dim su As StringUtils
    Return su.EncodeBase64(e)
End Sub


However, the same files now must be decrypted by another application, written natively (by another developer) in swift/xcode.
Not being a security expert, i thought this to be a trivial matter, but i've been told that the b4x implementation uses bouncycastle, and is not standard AES.

Is there a simple way, or a library to do what b4XCipher does but in swift/c ?

If not so, what is the recommended way to crypt/decrypt for a multiplatform context? I don't mind changing library/standard if needed.

Thanks for the time and sorry if the post isn't clear..... until now encryption for me was just a library call, and i'm just starting to learn about salt, initialization vectors, protocols etc
 

agraham

Expert
Licensed User
Longtime User
It uses AES with a random salt and random IV. The salt and IV (which are not considered sensitive information) are saved at the beginning of the data.
You should be able to decrypt on any platform that implements AES.
 
Upvote 0

Pxs

Member
Licensed User

You should be able to decrypt on any platform that implements AES.
Thanks for the replies

I'm not an ObjC programmer, but i was told the problem is in the lack of native support for BouncyCastle in Swift.

Searching around, i found something on cocoapods https://cocoapods.org/pods/BouncyCastle-ObjC
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I'm not an ObjC programmer, but i was told the problem is in the lack of native support for BouncyCastle in Swift.
BouncyCastle is irrelevant. It is just an implementation of AES, amongst other things. I don't know iOS but I'm sure there must be AES implementations for it in which case it can decode B4XCipher.
 
Upvote 1
Top