Permalink
Browse files

added README.md

  • Loading branch information...
1 parent 2b955b9 commit 9676f8c482ab1329c10479627d029f4ac014a0db @xcatsan xcatsan committed Jun 2, 2011
Showing with 147 additions and 0 deletions.
  1. +2 −0 FBEncryptor.xcodeproj/project.pbxproj
  2. +145 −0 README.md
View
2 FBEncryptor.xcodeproj/project.pbxproj
@@ -63,6 +63,7 @@
4C1000DF1393250900C9257E /* FBEncryptorAES.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBEncryptorAES.m; sourceTree = "<group>"; };
4C10010C13932FC400C9257E /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Base64.m"; sourceTree = "<group>"; };
4C10010D13932FC400C9257E /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Base64.h"; sourceTree = "<group>"; };
+ 4C7E35C313974826000D7909 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -92,6 +93,7 @@
4C100095139324DA00C9257E = {
isa = PBXGroup;
children = (
+ 4C7E35C313974826000D7909 /* README.md */,
4C1000DD139324F300C9257E /* FBEncryptor */,
4C1000AA139324DB00C9257E /* Test Application */,
4C1000CA139324DB00C9257E /* FBEncryptTests */,
View
145 README.md
@@ -0,0 +1,145 @@
+CCCrypt wrapper class
+=============================
+
+FBEncryptor is enabled to encrypt/decrypt a message. Supported encryption algorithm is AES 256 bit only. Additionally BASE64 encode/decode is supported.
+
+
+Usage
+-----
+
+(1) Encrypt/decrypt a plain text message with Base64 encoding
+
+ NSString* encrypted = [FBEncryptorAES encryptBase64String:@"Hello"
+ keyString:@"somekey"
+ separateLines:NO];
+
+The output string is encoded with Base64.
+ example)
+ message: @"Hello"
+ output : @"gT2IUF9Jzmn7wglXk3XC3w=="
+
+if 'separateLines' is NO, no CR/LF characters will be added.
+Otherwise a CR/LF pair will be added every 64 encoded chars.
+
+
+ NSString* decrypted = [FBEncryptorAES decryptBase64String:encrypted
+ keyString:key];
+
+
+
+(2) Encrypt/decrypt a binary
+
+ NSData* encryptedData = [FBEncryptorAES encryptData:data
+ keyData:key
+ iv:iv];
+
+ NSData* decryptedData = [FBEncryptorAES decryptData:encryptData
+ keyData:key
+ iv:iv];
+
+The 'iv' is initailization vector for CBC mode. it is abled to be set nil.
+
+
+(3) Generate iv
+
+ NSData* iv = [FBEncryptorAES generateIv];
+
+It generates a 16 bytes random binary value. You can use this iv value for +encryptData:keyData:iv:.
+
+
+(4) Utiities
+
+ NSData* iv = [FBEncryptorAES generateIv];
+ NSString* hexString = [FBEncryptorAES hexStringForData:iv];
+
+ example: @"b20cd8d972e65762824cc3190040388c"
+
+ NSData* bin = [FBEncryptorAES dataForHexString:hexString];
+
+
+
+Features
+--------
+- Only support AES256/CBC/PKCS7padding
+- Base64 encoding is suported
+
+
+Customize
+---------
+
+It is able to change below constants:
+ FBEncryptor.h
+ #define FBENCRYPT_KEY_SIZE kCCKeySizeAES256
+
+If you want to use AES 128 bit key, you can set the constant like below:
+ #define FBENCRYPT_KEY_SIZE kCCKeySizeAES128
+
+NOTE: If you change the constant, the testcase will be failed (it is made for AES 256 bit key).
+
+
+Installation
+-----------
+
+You should copy below files to your projects.
+
+ FBEncryptor.h
+ FBEncryptor.m
+ NSData+Base64.h
+ NSData+Base64.m
+
+
+Etc
+-------
+Special thanks for Matt Gallagher (author of NSData+Base64 code).
+"Cocoa with Love: Base64 encoding options on the Mac and iPhone"
+http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html
+
+
+License
+-------
+(1) FBEncryptorAES.m/FBEncryptorAES.h
+
+MIT
+
+Copyright (c) 2011 Hiroshi Hashiguchi
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+
+(2) NSData+Base64.m/NSData+Base64.h
+
+Created by Matt Gallagher on 2009/06/03.
+Copyright 2009 Matt Gallagher. All rights reserved.
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software. Permission is granted to anyone to
+use this software for any purpose, including commercial applications, and to
+alter it and redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source
+ distribution.
+
+

0 comments on commit 9676f8c

Please sign in to comment.