{"id":20432853,"url":"https://github.com/areroketahi/swiftlycrypto","last_synced_at":"2025-06-28T18:35:21.863Z","repository":{"id":190429352,"uuid":"682583245","full_name":"AreroKetahi/SwiftlyCrypto","owner":"AreroKetahi","description":"Encrypt your data like using other Swift APIs","archived":false,"fork":false,"pushed_at":"2023-10-22T07:06:35.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-03T11:09:41.680Z","etag":null,"topics":["aes-encryption","crypto","cryptography","encryption","rsa","swift","swift-package-manager","swiftly"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AreroKetahi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-24T13:36:34.000Z","updated_at":"2023-12-31T19:03:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"a6304666-4745-4713-b4be-449fcc5eb3e1","html_url":"https://github.com/AreroKetahi/SwiftlyCrypto","commit_stats":null,"previous_names":["areroketahi/swiftlycrypto"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/AreroKetahi/SwiftlyCrypto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreroKetahi%2FSwiftlyCrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreroKetahi%2FSwiftlyCrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreroKetahi%2FSwiftlyCrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreroKetahi%2FSwiftlyCrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AreroKetahi","download_url":"https://codeload.github.com/AreroKetahi/SwiftlyCrypto/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AreroKetahi%2FSwiftlyCrypto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262477083,"owners_count":23317413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aes-encryption","crypto","cryptography","encryption","rsa","swift","swift-package-manager","swiftly"],"created_at":"2024-11-15T08:16:58.249Z","updated_at":"2025-06-28T18:35:21.843Z","avatar_url":"https://github.com/AreroKetahi.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftlyCrypto\n\n![GitHub](https://img.shields.io/github/license/AreroKetahi/SwiftlyCrypto)\n![GitHub release (with filter)](https://img.shields.io/github/v/release/AreroKetahi/SwiftlyCrypto)\n\n![Static Badge](https://img.shields.io/badge/Swift_Package_Manager-compatible-default?logo=swift\u0026logoColor=white)\n\nEncrypt your data like using other Swift APIs\n\nSwiftlyCrypto is based on [SwCrypt](https://github.com/soyersoyer/SwCrypt) from [@soyersoyer](https://github.com/soyersoyer)\n\n## Why SwiftlyCrypto? \n\nSwiftlyCrypto is a non-abstract crypto library. Developers can benefit from SwiftlyCrypto's figurative API.\n\nSwiftlyCrypto will never define a type as its original value. (Like `Data` or `String`.) This feature can be very useful in large projects, because it makes the code more readable.\n\nSwiftlyCrypto is repackaged from SwCryt. Thanks [@soyersoyer](https://github.com/soyersoyer)'s project [SwCrypt](https://github.com/soyersoyer/SwCrypt)!\n\n# Quick Tutorial\n\nYou should import SwiftlyCrypto to your code at the beginning.\n\n```swift\nimport SwiftlyCrypto\n```\n\n## RSA\n\n### Generate key pair\n\n```swift\nlet (privateKey, publicKey) = RSA.generateKeyPair()\n```\n\n### Get PEM format keys\n\n```swift\nlet pemPrivateKey = privateKey.toPKCS1()\nlet pemPublicKey = publicKey.toPKCS8()\n```\n\n### Encrypt \u0026 decrypt private key\n\n```swift\nlet encryptedPrivateKey = try privateKey.encryptedKey(\"password\")\nlet decryptedPrivateKey = try RSAPrivateKey(encryptedPrivateKey, password: \"password\")\n```\n\n### Get public key from private key\n\n```swift\nlet publicKey = try privateKey.getPublicKey()\n```\n\n### Encrypt \u0026 Decrypt\n\n```swift\nlet text = \"Hello, world!\"\nlet raw = RSARawValue(text)\nlet encrypted = try raw.encrypt(publicKey: publicKey)\nlet decrypted = try encrypted.decrypt(privateKey: privateKey)\n```\n\n### Sign \u0026 Verify\n\n```swift\nlet text = \"Hello, world!\"\nlet raw = RSARawValue(text)\nlet signed = try raw.sign(privateKey: privateKey)\nlet verifyResult = try signed.verify(message: raw, publicKey: publicKey) // true for success, otherwise false\n```\n\n## AES\n\n### Generate random Key \u0026 IV\n\n```swift\nlet randomKey = AES.generateRandomKey()\nlet randomIV = AES.generateRandomIV()\n```\n\n### Set your own Key \u0026 IV\n\n```swift\nlet key = AESKey(\"password\")\nlet iv = try AESIV(fromHexString: \"12345678901234567890123456789012\")\n```\n\n### Encrypt \u0026 Decrypt\n\n```swift\nlet text = \"Hello, world!\"\nlet raw = AESRawValue(text)\nlet encrypted = try raw.encrypt(key: key, iv: iv)\nlet decrypted = try encrypted.decrypt(key: key, iv: iv)\n```\n\n### Encrypt with random generation\n\n```swift\n// generate both key and iv\nlet raw = AESRawValue(\"Hello, world!\")\nlet key = AESKey()\nlet iv = AESIV()\nlet encrypted = try raw.encrypt(randomKey: \u0026key, randomIV: \u0026iv)\n```\n\n```swift\n// generate key\nlet raw = AESRawValue(\"Hello, world!\")\nlet key = AESKey()\nlet iv = try AESIV(fromHexString: \"12345678901234567890123456789012\")\nlet encrypted = try raw.encrypt(randomKey: \u0026key, iv: iv)\n```\n\n```swift\n// generate iv\nlet raw = AESRawValue(\"Hello, world!\")\nlet key = AESKey(\"password\")\nlet iv = AESIV()\nlet encrypted = try raw.encrypt(key: key, randomIV: \u0026iv)\n```\n\n### Check whether the key or IV is empty\n\n```swift\n// true for empty, otherwise false\nkey.isEmpty\niv.isEmpty\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fareroketahi%2Fswiftlycrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fareroketahi%2Fswiftlycrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fareroketahi%2Fswiftlycrypto/lists"}