title: how to encrypt and decrypt a String(Plain Text) with RSA public key in ios, swift
body: <p>I want to <code>Encrypt</code> a string(Plain Text) with my <code>RSA</code> public key. I have a <code>public key</code>, which sent from the server as a <code>String</code> and with that I created a <code>RSA</code> public key. now I want to use that key to <code>Encrypt</code> my text with padding <code>PKACS12</code>. how can I do that. I went through lots of stack overflow questions and I didn't get any success. </p>
  
  <p>this is how I create the <code>RSA public key</code>,</p>
  
  <pre><code>let serverPublicKey = "Some text with key"
  
  let data2 = Data.init(base64Encoded: serverPublicKey)
  
  let keyDict:[NSObject:NSObject] = [
    kSecAttrKeyType: kSecAttrKeyTypeRSA,
    kSecAttrKeyClass: kSecAttrKeyClassPublic,
    kSecAttrKeySizeInBits: NSNumber(value: 2048),
    kSecReturnPersistentRef: true as NSObject
   ]
  
  let publickeysi = SecKeyCreateWithData(data2! as CFData, keyDict as CFDictionary, nil)
  </code></pre>
  
  <p>this creates a <code>RSA public key</code> successfully. now I want to use this key to encrypt my another <code>Plain Text</code>. how can I do that.</p>