{"id":1945,"url":"https://github.com/jancassio/SweetHMAC","last_synced_at":"2025-08-02T05:33:16.713Z","repository":{"id":25539046,"uuid":"28971698","full_name":"jancassio/SweetHMAC","owner":"jancassio","description":"A tiny and easy to use Swift class to encrypt strings using HMAC algorithms.","archived":true,"fork":false,"pushed_at":"2016-10-20T02:31:44.000Z","size":126,"stargazers_count":38,"open_issues_count":5,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-28T04:38:29.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://jancassio.github.io/SweetHMAC","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/jancassio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-08T15:21:00.000Z","updated_at":"2025-04-23T02:26:11.000Z","dependencies_parsed_at":"2022-08-24T02:40:07.596Z","dependency_job_id":null,"html_url":"https://github.com/jancassio/SweetHMAC","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jancassio/SweetHMAC","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jancassio%2FSweetHMAC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jancassio%2FSweetHMAC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jancassio%2FSweetHMAC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jancassio%2FSweetHMAC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jancassio","download_url":"https://codeload.github.com/jancassio/SweetHMAC/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jancassio%2FSweetHMAC/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268339405,"owners_count":24234544,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-01-05T20:15:59.596Z","updated_at":"2025-08-02T05:33:16.354Z","avatar_url":"https://github.com/jancassio.png","language":"Swift","funding_links":[],"categories":["Security","Libs","Frameworks and Libs"],"sub_categories":["Encryption","Other free courses","Security","Swift"],"readme":"#Sweet HMAC\n\n[![Twitter: @jancassio](https://img.shields.io/badge/contact-@jancassio-blue.svg?style=flat)](https://twitter.com/jancassio)\n[![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/jancassio/SweetHMAC/blob/master/LICENSE)\n[![Build](https://api.travis-ci.org/jancassio/SweetHMAC.svg)](https://travis-ci.org/jancassio/SweetHMAC)\n![Version](https://cocoapod-badges.herokuapp.com/v/SweetHMAC/badge.png)\n![Platforms](https://cocoapod-badges.herokuapp.com/p/SweetHMAC/badge.png)\n\n`SweetHMAC` is a tiny and easy to use Swift class to encrypt strings using HMAC algorithms.\nA special thanks to [jernejstrasner](https://gist.github.com/jernejstrasner) for shared [HMACDigest Gist](https://gist.github.com/jernejstrasner/1d5fa5e2fabda2e729d1), that inspired to create this simple class and String extension.\n\n## Usage examples\n\nThere are two ways to use Sweet HMAC in your projects\n\n### 1. by String extension\n```swift\n// Will output this string: e470f785afb708cd8c2a31860642fd11\n\"I'm going to make him an offer he can't refuse\".HMAC(.md5, secret:\"Vito Corleone\")\n```\n\n### 2. by SweetHMAC class\n\n```swift\nlet quote = \"I'm going to make him an offer he can't refuse\"\nlet author = \"Vito Corleone\"\n\n// Create a SweetHMAC instance with your message and secret strings\nlet digest:SweetHMAC = SweetHMAC(message: quote, secret: author)\n\n// Pick some computed HMAC output based on some algorithm using \"HMAC\" method...\nlet md5 = digest.HMAC(algorithm: .md5)\n\n// ...or do it more \"Sweet\" like this\nlet md5 = SweetHMAC(message: quote, secret: author).HMAC(.MD5)\n```\n\n## Supported HMAC algorithms\n\n* MD5\n* SHA1\n* SHA224\n* SHA256\n* SHA384\n* SHA512\n\n## Installation\n\nSweetHMAC have many clear and simple options to be used in any iOS or OSX projects.\n\n##Using dependency manager\nActually SweetHMAC can be used with those dependency managers\n* CocoaPods\n* Carthage\n\n###CocoaPods\n\nYou can use SweetHMAC with CocoaPods, specify your `Podfile` like this:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '9.0'\nuse_frameworks!\n\npod 'SweetHMAC', '~\u003e 3.0'\n```\n\n##Carthage\n\nAlso you can use Carthage to SweetHMAC framework at your project, just add SweetHMac in your `Cartfile` file like this:\n\n`github \"jancassio/SweetHMAC\" \u003e= 3.0`\n\n##Integrated Project\n\nAs many iOS/OSX projects, you can add third party libraries in your project as well.\n\n###Embeded Framework\n\nYou can add SweetHMAC as submodule (preferred) or paste entire SweetHMAC project relative to your Xcode project, choose one of both options and after them:\n\n  1. Drag `SweetHMAC.xcodeproj` from SweetHMAC folder to your project.\n  2. At Xcode, open _\"Project Navigator\"_ (⌘+1).\n  3. Select SweetHMAC project (the blue project icon).\n  4. Check if SweetHMAC deployment target matches your project deployment target.\n  5. At this point, select _\"Build Phases\"_ tab.\n  6. Click on **+** icon to add a new _\"Copy Phase\"_. Optional: Rename this phase to _\"Embeded Frameworks\"_.\n  7. Set destination to _\"Frameworks\"_.\n  8. Add `SweetHMAC.framework`.\n\n### Source file\n\nThis is not the preferred option to add SweetHMAC in your project, because SweetHMAC depends by CommonCrypto lib to work properly and, Swift can't access this lib directly.\n\nSo if you still want to use SweetHMAC by source files, follow steps below:\n\n  1. At Xcode, open _\"Project Navigator\"_ (⌘+1).\n  2. Select your project file (the blue project icon).\n  3. Click on _\"Build Phases\"_ tab.\n  4. Create a new _\"Run Script\"_ phase clicking on **+** icon.\n  5. Drag the run script phase created to stay below the first phase (ak _\"Target dependencies\"_).\n  6. Paste the code below at run script phase created before:\n\n  ```shell\n  COMMOM_CRYPTO_PATH=$SDKROOT/usr/include/CommonCrypto/CommonCrypto.h\n  COMMOM_CRYPTO_R_PATH=$SDKROOT/usr/include/CommonCrypto/CommonRandom.h\n\n  MODULE_DIR=\"$SRCROOT/Modules/CommonCrypto\"\n  MODULE_FILE=$MODULE_DIR/module.map\n  MODULE_TEMPLATE=\"module CommonCrypto [system] {\\n\\t\n    header \\\"$COMMOM_CRYPTO_PATH\\\"\\n\\t\n    header \\\"$COMMOM_CRYPTO_R_PATH\\\"\\n\\t\n    export *\\n\n  }\"\n\n  echo \"Create Modules path to map CommonCrypto lib\"\n  mkdir -p \"$SRCROOT/Modules/CommonCrypto\"\n\n  echo \"Cleanup previous CommonCrypto script to make sure the deployment target is always updated\"\n\n  echo \"\" \u003e $MODULE_FILE\n\n  echo \"Create CommonCrypto module map template\"\n  echo -e $MODULE_TEMPLATE \u003e $MODULE_FILE\n  ```\n\n  7. Create a new file (⌘+N).\n  8. Select _\"iOS\"_/_\"Others\"_.\n  9. Select _\"Congfiguration Settings File\"_.\n  10. Put any name you want.\n  10. Add the content below in Configuration file created before:\n  ```\n  SWIFT_INCLUDE_PATHS=\"$SRCROOT/Modules\"\n  ```\n  12. Go to your project file in _\"Project Navigator\"_ (⌘+1)\n  13. Select your project file and select your project above your project targets.\n  14. Change configurations for the last one you created for each target you are using SweetHMAC by source.\n  15. Build your project.\n\n###Quick Observation\nEach time you change your deployment device for example, from Simulator to Device, you should build your project, because the script added in build phase, will use the current operational system selected in your Xcode scheme to construct the absolute path to the CommonCrypto header relative of Simulator SDK or iPhoneOS SDK.\n\n## License\n\nCopyright (c) 2014 Jan Cassio. All rights reserved.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjancassio%2FSweetHMAC","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjancassio%2FSweetHMAC","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjancassio%2FSweetHMAC/lists"}