Permalink
Browse files

EDFuzz class

  • Loading branch information...
1 parent f564c9e commit c58c2cd5bef8b5346c37c1eeeeb00fe0f80a36d8 @thisandagain committed Sep 7, 2012
Showing with 41 additions and 0 deletions.
  1. +15 −0 EDAssert/EDFuzz.h
  2. +26 −0 EDAssert/EDFuzz.m
View
15 EDAssert/EDFuzz.h
@@ -0,0 +1,15 @@
+//
+// EDFuzz.h
+// connect
+//
+// Created by Andrew Sliwinski on 9/7/12.
+// Copyright (c) 2012 DIY, Co. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface EDFuzz : NSObject
+
++ (NSString *)withLength:(NSUInteger)length;
+
+@end
View
26 EDAssert/EDFuzz.m
@@ -0,0 +1,26 @@
+//
+// EDFuzz.m
+// connect
+//
+// Created by Andrew Sliwinski on 9/7/12.
+// Copyright (c) 2012 DIY, Co. All rights reserved.
+//
+
+#import "EDFuzz.h"
+
+@implementation EDFuzz
+
++ (NSString *)withLength:(NSUInteger)length
+{
+ NSString *alphabet = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXZY0123456789!@#$%^&*()_+{}|][=-';:`~? ";
+ NSMutableString *s = [NSMutableString stringWithCapacity:length];
+ for (NSUInteger i = 0U; i < length; i++) {
+ u_int32_t r = arc4random() % [alphabet length];
+ unichar c = [alphabet characterAtIndex:r];
+ [s appendFormat:@"%C", c];
+ }
+
+ return s;
+}
+
+@end

0 comments on commit c58c2cd

Please sign in to comment.