1

I had tried to do AES256 encryption in Swift3, by using many libraries like CryptoSwift, but couldnt get proper result.

 let aes = try AES(key: anykey, iv: "") let ciphertext = try aes.encrypt(data) 

The mode I want to try is as below.

Algorithm: Rijndael-256 MODE:  ECB IV: NULL 

if there is mistake in my code, or any better way to AES256 encrypt in Swift3, answer me please.

2 Answers 2

3

RNCryptor is a useful framework for AES256 encryption and decryption.

// Encryption let data ... // Some data you want to encrypt let password = "0Bfy8q9475jgjjbsu" let ciphertext = RNCryptor.encryptData(data, password: password) // Decryption do { let originalData = try RNCryptor.decryptData(ciphertext, password: password) } catch let error { print("Can not Decrypt With Error: \n\(error)\n") } 
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, I will try this
Sure thing. It works I have used it before in several projects. Once you get it fired up it is just plug and go. I had some initial troubles in the beginning. See my own question for more information stackoverflow.com/q/40685174/3911918
None of my apps have been rejected that use this.
@Brandon A thank u for your quick response, one more doubt i have, should i need to do U.S. Export Compliance process to use this.
0

You could also try the CommonCrypto C library which RNCryptor wraps. This comes as standard with XCode. Unfortunately it doesn't have a swift framework setup for it. This project creates a framework for easy use in swift https://github.com/sergejp/CommonCrypto/tree/master/CommonCrypto

You can find example code using the CommonCrypto library here https://github.com/adam-fowler/swift-library/blob/master/data/aes.swift.

1 Comment

Fixed the link now

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.