Skip to content

Library provides a set of tools for working with RSA cryptographic algorithm

Notifications You must be signed in to change notification settings

valery-bashkatov/RSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RSA

Library provides a set of tools for working with RSA cryptographic algorithm.

Requirements

  • iOS 9.0+
  • Swift 4.1+

Installation

Carthage

To integrate RSA into your project using Carthage, specify it in your RSA:

github "valery-bashkatov/RSA" ~> 2.0.0

And then follow the instructions to install the framework.

Documentation

API Reference is located at http://valery-bashkatov.github.io/RSA.

Usage

import Security
import RSA

let text = "Lorem ipsum dolor sit amet..."

var publicKey: SecKey
var privateKey: SecKey

// Key pair generation
(publicKey, privateKey) = try! RSA.generateKeyPair(withSize: 2048)

// Encryption
let encryptedData: Data = try! RSA.encrypt(data: text.data(using: .utf8)!, using: publicKey)

// Decryption
let decryptedData: Data = try! RSA.decrypt(data: encryptedData, using: privateKey)

// Signing
let signature: Data = try! RSA.sign(encryptedData, using: privateKey, digestAlgorithm: .PKCS1SHA1)

// Verification
let verificationResult: Bool = try! RSA.verify(encryptedData, using: publicKey, digestAlgorithm: .PKCS1SHA1, signature: signature)

// Key's data
let data: Data = publicKey.data

// Key's PEM
let pem: String = publicKey.pem

// Key creation from data
let publicKeyFromData: SecKey = try! SecKey.make(from: data, isPublicKey: true)

// Key creation from PEM
let publicKeyFromPEM: SecKey = try! SecKey.make(fromPEM: pem, isPublicKey: true)

About

Library provides a set of tools for working with RSA cryptographic algorithm

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published