Here is my code, and what is supposed to do, is encrypt text with imported certificate as .pem. I imported RSAUtils.swift in the code, and both certificates but I havent done anything in .plist file (I'm not sure if something should be done or not) and the other doubdt that I have is about the com.company.tag_private line. What should I put there instead of 'company'? I tried with my name, but didn't work.
Everything seems to be fine (no errors) untill I launch the app and try to encrypt text, the just nothing happens - no text is output. What am I missing?
This is my code:
@IBOutlet weak var messageToDecrypt: UITextView!
@IBOutlet weak var decryptedMessageLabel: UITextView!
/
let privatekey = "com.company.tag_private"
/
let publickey = "com.company.tag_public"
@IBAction func decrypt(sender: AnyObject) {
func decrypt() {
let privatekey = getKeyStringFromPEM(name: "private_key_pkcs8")
let message = messageToDecrypt.text
let data = message?.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))
let decryptedData:NSData? = RSAUtils.decryptWithRSAPrivateKey(data!, privkeyBase64: privatekey, keychainTag: privatekey) as NSData?
let decryptedMessage = decryptedData?.base64EncodedString(options: NSData.Base64EncodingOptions())
decryptedMessageLabel.text = decryptedMessage
}
}
override func viewDidLoad() {
super.viewDidLoad()
messageToDecrypt.delegate = self
decryptedMessageLabel.delegate = self
}