title: How to encrypt using S/MIME encryption by OpenSSL Universe in swift
body: <p>I have OpenSSL Universe installed in Xcode and also have the decryption function for decrypting from encrypted S/MIME. But I need to encrypt first. Is there any built in function in Swift that uses OpenSSL (PKS7) for encryption. Or how can I do S/MIME encryption.</p>
  <p>Here is my decryption function -</p>
  <pre><code>class func decrypt(_ encrypted: String?, privateKey: String?, certificate: String?) -&gt; String? {
          let enc = encrypted ?? &quot;0&quot;
          let pk = privateKey ?? &quot;0&quot;
          let cert = certificate ?? &quot;0&quot;
          let decrypted = decrypt(enc, privateKey: pk, certificate: cert)
          if let decrypted = decrypted {
              return String(utf8String: decrypted)
          } else {
              return nil
          }
      }
  </code></pre>