aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDataAdditions.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPDataAdditions.m')
-rw-r--r--Source/SPDataAdditions.m73
1 files changed, 0 insertions, 73 deletions
diff --git a/Source/SPDataAdditions.m b/Source/SPDataAdditions.m
index 805692c6..0329395c 100644
--- a/Source/SPDataAdditions.m
+++ b/Source/SPDataAdditions.m
@@ -33,81 +33,8 @@
#include <openssl/aes.h>
#include <openssl/sha.h>
-static char base64encodingTable[64] = {
-'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
-'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
-'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
-'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' };
-
@implementation NSData (SPDataAdditions)
-/*
- * Derived from http://colloquy.info/project/browser/trunk/NSDataAdditions.m?rev=1576
- * Created by khammond on Mon Oct 29 2001.
- * Formatted by Timothy Hatcher on Sun Jul 4 2004.
- * Copyright (c) 2001 Kyle Hammond. All rights reserved.
- * Original development by Dave Winer.
- *
- * Convert self to a base64 encoded NSString
- */
-- (NSString *) base64EncodingWithLineLength:(NSUInteger)lineLength {
-
- const unsigned char *bytes = [self bytes];
- NSUInteger ixtext = 0;
- NSUInteger lentext = [self length];
- NSInteger ctremaining = 0;
- unsigned char inbuf[3], outbuf[4];
- NSUInteger i = 0;
- NSUInteger charsonline = 0, ctcopy = 0;
- NSUInteger ix = 0;
-
- NSMutableString *base64 = [NSMutableString stringWithCapacity:lentext];
-
- while(1) {
- ctremaining = lentext - ixtext;
- if( ctremaining <= 0 ) break;
-
- for( i = 0; i < 3; i++ ) {
- ix = ixtext + i;
- if( ix < lentext ) inbuf[i] = bytes[ix];
- else inbuf [i] = 0;
- }
-
- outbuf [0] = (inbuf [0] & 0xFC) >> 2;
- outbuf [1] = ((inbuf [0] & 0x03) << 4) | ((inbuf [1] & 0xF0) >> 4);
- outbuf [2] = ((inbuf [1] & 0x0F) << 2) | ((inbuf [2] & 0xC0) >> 6);
- outbuf [3] = inbuf [2] & 0x3F;
- ctcopy = 4;
-
- switch( ctremaining ) {
- case 1:
- ctcopy = 2;
- break;
- case 2:
- ctcopy = 3;
- break;
- }
-
- for( i = 0; i < ctcopy; i++ )
- [base64 appendFormat:@"%c", base64encodingTable[outbuf[i]]];
-
- for( i = ctcopy; i < 4; i++ )
- [base64 appendFormat:@"%c",'='];
-
- ixtext += 3;
- charsonline += 4;
-
- if( lineLength > 0 ) {
- if (charsonline >= lineLength) {
- charsonline = 0;
- [base64 appendString:@"\n"];
- }
- }
- }
-
- return base64;
-}
-
- (NSData *)dataEncryptedWithPassword:(NSString *)password
{
// Create a random 128-bit initialization vector