{"id":13611077,"url":"https://github.com/kelp404/CocoaSecurity","last_synced_at":"2025-04-13T01:34:31.200Z","repository":{"id":3288913,"uuid":"4329779","full_name":"kelp404/CocoaSecurity","owner":"kelp404","description":"Encrypt/Decrypt: AES. Hash: MD5, SHA(SHA1, SHA224, SHA256, SHA384, SHA512). Encode/Decode: Base64, Hex.","archived":false,"fork":false,"pushed_at":"2020-01-04T10:12:05.000Z","size":522,"stargazers_count":1133,"open_issues_count":6,"forks_count":190,"subscribers_count":44,"default_branch":"master","last_synced_at":"2024-11-01T01:33:52.452Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/kelp404.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2012-05-14T22:31:19.000Z","updated_at":"2024-10-26T07:25:09.000Z","dependencies_parsed_at":"2022-08-26T02:50:25.419Z","dependency_job_id":null,"html_url":"https://github.com/kelp404/CocoaSecurity","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelp404%2FCocoaSecurity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelp404%2FCocoaSecurity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelp404%2FCocoaSecurity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelp404%2FCocoaSecurity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kelp404","download_url":"https://codeload.github.com/kelp404/CocoaSecurity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222806241,"owners_count":17040426,"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":[],"created_at":"2024-08-01T19:01:51.553Z","updated_at":"2024-11-07T17:31:19.269Z","avatar_url":"https://github.com/kelp404.png","language":"Objective-C","readme":"#CocoaSecurity [![Build Status](https://secure.travis-ci.org/kelp404/CocoaSecurity.png?branch=master)](http://travis-ci.org/#!/kelp404/CocoaSecurity)\n\nKelp https://twitter.com/kelp404/  \n[MIT License][mit]  \n[MIT]: http://www.opensource.org/licenses/mit-license.php\n\n\nCocoaSecurity include 4 classes, `CocoaSecurity`, `CocoaSecurityResult`, `CocoaSecurityEncoder` and `CocoaSecurityDecoder`.\n\n##CocoaSecurity\nCocoaSecurity is core. It provides AES encrypt, AES decrypt, Hash(MD5, HmacMD5, SHA1~SHA512, HmacSHA1~HmacSHA512) messages.  \n  \n**MD5:**\n```objective-c\nCocoaSecurityResult *md5 = [CocoaSecurity md5:@\"kelp\"];\n\n// md5.hex = 'C40C69779E15780ADAE46C45EB451E23'\n// md5.hexLower = 'c40c69779e15780adae46c45eb451e23'\n// md5.base64 = 'xAxpd54VeAra5GxF60UeIw=='\n```\n**SHA256:**\n```objective-c\nCocoaSecurityResult *sha256 = [CocoaSecurity sha256:@\"kelp\"];\n\n// sha256.hexLower = '280f8bb8c43d532f389ef0e2a5321220b0782b065205dcdfcb8d8f02ed5115b9'\n// sha256.base64 = 'KA+LuMQ9Uy84nvDipTISILB4KwZSBdzfy42PAu1RFbk='\n```\n**default AES Encrypt:**\u003cbr/\u003e\nkey -\u003e SHA384(key).sub(0, 32)\u003cbr/\u003e\niv -\u003e SHA384(key).sub(32, 16)\n```objective-c\nCocoaSecurityResult *aesDefault = [CocoaSecurity aesEncrypt:@\"kelp\" key:@\"key\"];\n\n// aesDefault.base64 = 'ez9uubPneV1d2+rpjnabJw=='\n```\n**AES256 Encrypt \u0026 Decrypt:**\n```objective-c\nCocoaSecurityResult *aes256 = [CocoaSecurity aesEncrypt:@\"kelp\"\n                                      hexKey:@\"280f8bb8c43d532f389ef0e2a5321220b0782b065205dcdfcb8d8f02ed5115b9\"\n                                       hexIv:@\"CC0A69779E15780ADAE46C45EB451A23\"];\n// aes256.base64 = 'WQYg5qvcGyCBY3IF0hPsoQ=='\n\nCocoaSecurityResult *aes256Decrypt = [CocoaSecurity aesDecryptWithBase64:@\"WQYg5qvcGyCBY3IF0hPsoQ==\" \n                                      hexKey:@\"280f8bb8c43d532f389ef0e2a5321220b0782b065205dcdfcb8d8f02ed5115b9\"\n                                       hexIv:@\"CC0A69779E15780ADAE46C45EB451A23\"];\n// aes256Decrypt.utf8String = 'kelp'\n```\n\n\n##CocoaSecurityResult\nCocoaSecurityResult is the result class of CocoaSecurity. It provides convert result data to NSData, NSString, HEX string, Base64 string.\n\n```objective-c\n@property (strong, nonatomic, readonly) NSData *data;\n@property (strong, nonatomic, readonly) NSString *utf8String;\n@property (strong, nonatomic, readonly) NSString *hex;\n@property (strong, nonatomic, readonly) NSString *hexLower;\n@property (strong, nonatomic, readonly) NSString *base64;\n```\n\n\n##CocoaSecurityEncoder\nCocoaSecurityEncoder provides convert NSData to HEX string, Base64 string.\n\n```objective-c\n- (NSString *)base64:(NSData *)data;\n- (NSString *)hex:(NSData *)data useLower:(BOOL)isOutputLower;\n```\n**example:**\n```objective-c\nCocoaSecurityEncoder *encoder = [CocoaSecurityEncoder new];\nNSString *str1 = [encoder hex:[@\"kelp\" dataUsingEncoding:NSUTF8StringEncoding] useLower:NO];\n// str1 = '6B656C70'\nNSString *str2 = [encoder base64:[@\"kelp\" dataUsingEncoding:NSUTF8StringEncoding]];\n// str2 = 'a2VscA=='\n```\n\n##CocoaSecurityDecoder\nCocoaSecurityEncoder provides convert HEX string or Base64 string to NSData.\n\n```objective-c\n- (NSData *)base64:(NSString *)data;\n- (NSData *)hex:(NSString *)data;\n```\n**example:**\n```objective-c\nCocoaSecurityDecoder *decoder = [CocoaSecurityDecoder new];\nNSData *data1 = [decoder hex:@\"CC0A69779E15780ADAE46C45EB451A23\"];\n// data1 = \u003ccc0a6977 9e15780a dae46c45 eb451a23\u003e\nNSData *data2 = [decoder base64:@\"zT1PS64MnXIUDCUiy13RRg==\"];\n// data2 = \u003ccd3d4f4b ae0c9d72 140c2522 cb5dd146\u003e\n```\n\n\n##Installation\n1. **git:**\n```\n$ git clone git://github.com/kelp404/CocoaSecurity.git\n$ cd CocoaSecurity\n$ git submodule update --init\n```\n\n2. **\u003ca href=\"http://cocoapods.org/?q=CocoaSecurity\" target=\"_blank\"\u003eCocoadPods\u003c/a\u003e:**  \nadd `Podfile` in your project path\n```\nplatform :ios\npod 'CocoaSecurity'\n```\n```\n$ pod install\n```\n","funding_links":[],"categories":["Objective-C","Frameworks and Libs","Data/File Archive \u0026 Unarchive","etc","OOM-Leaks-Crash"],"sub_categories":["Objective-C","数据安全和算法"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelp404%2FCocoaSecurity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkelp404%2FCocoaSecurity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelp404%2FCocoaSecurity/lists"}