RNCryptor: Crash on deinit of Decryptor in Xcode 10b3

Hi, first of all thank you for this great library!

Im using Swift version for quite some time now and after updating to xcode 10 beta 3 im getting crash every time i run the app. so i created new project in xcode 10 beta 3 and added rncryptor through pods 5.0.3 version. in my view did load i have below code

` // Encryption let text = “text to encrypr” let data = text.data(using: String.Encoding.utf8) let encryptedData = RNCryptor.encrypt(data: data!, withPassword: “pass”)

    encryptedText = encryptedData.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0))
    
    print("original text: \(text)")
    print("encrypted text: \(encryptedText)")
    
    
    var decryptedText = ""
    
    //convert encrypted string to data
    let dataToDecrypt = NSData(base64Encoded: encryptedText, options: NSData.Base64DecodingOptions(rawValue: 0))
    
    // Decryption
    do {
        let originalData = try RNCryptor.decrypt(data: dataToDecrypt! as Data, withPassword: "pass")
        decryptedText = String(data: originalData, encoding: String.Encoding.utf8)!
    } catch {
        print(error)
    }
    
    print("decrypted text: \(decryptedText)")

`

what i want is to encrypt a String, then convert the Data and save it to firebase. this part works, but when i want to decrypt the String that i saved to firebase the problems start.

if i pass encryptedData that I get from RNCryptor to the decryptor, it works fine, but when i convert my base64 dtring to data and pass it to decryptor it crashes.

let originalData = try RNCryptor.decrypt(data: encryptedData, withPassword: "pass") This exact code was working fine on swift 4 and xcode 9.x.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Does anyone else get this warning? I get it every now and then, after cleaning it it goes away (using xCode 10 beta 4 now, but it appears throughout xCode 10)

screen shot 2018-07-19 at 19 08 29

@papley I found it through minimization. I just kept removing more and more of the code until I found the smallest bit of code that reproduces the problem (see the Swift bug report for the final version). I then altered each piece of that code to see what mattered (changing which class, class/struct, private/public/internal, removing/adding properties, removing/adding functions). In the end, the change that made the problem go away but didn’t alter the code was removing the private.