Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void) BuildKey : ( unsigned long ) ASCIIValue
- {
- //key can be any number of characters.
- //set number of rings to make
- int columns = 4;
- NSMutableArray *letterArray = [NSMutableArray array];
- unsigned long iletters = [keyLetters length];
- [keyLetters enumerateSubstringsInRange:NSMakeRange(0, iletters) options:(NSStringEnumerationByComposedCharacterSequences)
- usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {[letterArray addObject:substring];}];
- //unscrambled ascii table of usable characters
- NSArray *outputChars = [self MakeASCIIArray];
- //should be 37, we'll not want to change this (A-Z 0-9 . )
- unsigned long rows = [keyLetters length];
- int t = 1;
- unsigned long rollingVal = 0;
- unsigned long val = ASCIIValue;
- for(int column = 1; column <= columns; column++)
- {
- for(int row = 1; row <= rows; row++)
- {
- unsigned long div = (val / 94) + t + column + row;
- rollingVal += div ^ val + t;
- unsigned long outPutIndex = (rollingVal + t + column + row) % [outputChars count];
- NSString *s = [NSString stringWithFormat:@"%@",[outputChars objectAtIndex:outPutIndex]];
- UIButton *button = (UIButton*)[self.MainView viewWithTag:t++];
- [button setTitle:s forState:UIControlStateNormal];
- NSLog(@"rollingVal: %lu outPut: %lu v: %@", rollingVal, outPutIndex, s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement