public
Description: A cross-platform web server that's scripted with Nu.
Homepage: http://programming.nu
Clone URL: git://github.com/timburks/nunja.git
Support for generation of md5 hashes.
timburks (author)
Sun Jun 01 14:58:58 -0700 2008
commit  ad036c71fe188bcc477effa313f6e8d8173dabf8
tree    1fe928f39521d194257cd9deac166861255ec0fe
parent  242d6ed9febd325f556257c263cba69754320b5b
...
6
7
8
9
 
10
11
12
13
 
14
15
16
...
6
7
8
 
9
10
11
12
 
13
14
15
16
0
@@ -6,11 +6,11 @@
0
 (case SYSTEM
0
       ("Darwin"
0
                (set @cflags "-g -DDARWIN")
0
- (set @ldflags "-framework Foundation -framework Nu -levent"))
0
+ (set @ldflags "-framework Foundation -framework Nu -levent -lcrypto"))
0
       ("Linux"
0
    (set @arch (list "i386"))
0
               (set @cflags "-g -DLINUX -I/usr/local/include -fconstant-string-class=NSConstantString ")
0
- (set @ldflags "-L/usr/local/lib -lNuFound -lNu -levent"))
0
+ (set @ldflags "-L/usr/local/lib -lNuFound -lNu -levent -lcrypto"))
0
       (else nil))
0
 
0
 ;; framework description
...
18
19
20
 
21
22
23
...
172
173
174
175
 
176
177
178
...
248
249
250
251
252
253
254
255
 
256
257
258
259
260
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
...
18
19
20
21
22
23
24
...
173
174
175
 
176
177
178
179
...
249
250
251
 
 
 
 
 
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
0
@@ -18,6 +18,7 @@ limitations under the License.
0
 
0
 #import "helpers.h"
0
 #import <arpa/inet.h>
0
+#import <openssl/md5.h>
0
 
0
 static unichar char_to_int(unichar c)
0
 {
0
@@ -172,7 +173,7 @@ static NSMutableDictionary *parseHeaders(const char *headers)
0
     return dict;
0
 }
0
 
0
-@implementation NSData (NuHTTP)
0
+@implementation NSData (Nunja)
0
 - (NSDictionary *) urlQueryDictionary
0
 {
0
     NSString *string = [[[NSString alloc] initWithData:self encoding:NSUTF8StringEncoding] autorelease];
0
@@ -248,14 +249,39 @@ static NSMutableDictionary *parseHeaders(const char *headers)
0
     return dict;
0
 }
0
 
0
-@end
0
-
0
-@implementation NSData (Nunja)
0
-
0
-+ dataWithSize:(int) size
0
++ (NSData *) dataWithSize:(int) size
0
 {
0
     const char *bytes = (char *) malloc (size * sizeof(char));
0
     return [self dataWithBytesNoCopy:bytes length:size freeWhenDone:YES];
0
 }
0
 
0
+static const char *const digits = "0123456789abcdef";
0
+
0
+- (NSString*) hex
0
+{
0
+ NSString *result = nil;
0
+ size_t length = [self length];
0
+ if (0 != length) {
0
+ NSMutableData *temp = [NSMutableData dataWithLength:(length << 1)];
0
+ if (temp) {
0
+ const unsigned char *src = [self bytes];
0
+ unsigned char *dst = [temp mutableBytes];
0
+ if (src && dst) {
0
+ while (length-- > 0) {
0
+ *dst++ = digits[(*src >> 4) & 0x0f];
0
+ *dst++ = digits[(*src++ & 0x0f)];
0
+ }
0
+ result = [[NSString alloc] initWithData:temp encoding:NSUTF8StringEncoding];
0
+ }
0
+ }
0
+ }
0
+ return (result) ? [result autorelease] : result;
0
+}
0
+
0
+- (NSData *) md5
0
+{
0
+ unsigned char *digest = MD5([self bytes], [self length], NULL);
0
+ return [NSData dataWithBytes:digest length:16];
0
+}
0
+
0
 @end

Comments

    No one has commented yet.