Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void) BuildKey : ( unsigned long ) ASCIIValue
  2. {
  3.     //key can be any number of characters.
  4.    
  5.     //set number of rings to make
  6.     int columns = 4;
  7.    
  8.     NSMutableArray *letterArray = [NSMutableArray array];
  9.     unsigned long iletters = [keyLetters length];
  10.     [keyLetters enumerateSubstringsInRange:NSMakeRange(0, iletters) options:(NSStringEnumerationByComposedCharacterSequences)
  11.     usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {[letterArray addObject:substring];}];
  12.    
  13.     //unscrambled ascii table of usable characters
  14.     NSArray *outputChars = [self MakeASCIIArray];
  15.    
  16.     //should be 37, we'll not want to change this (A-Z 0-9 . )
  17.     unsigned long rows = [keyLetters length];
  18.     int t = 1;
  19.     unsigned long rollingVal = 0;
  20.     unsigned long val = ASCIIValue;
  21.     for(int column = 1; column <= columns; column++)
  22.     {
  23.         for(int row = 1; row <= rows; row++)
  24.         {
  25.             unsigned long div = (val / 94) + t + column + row;
  26.             rollingVal += div ^ val + t;
  27.             unsigned long outPutIndex = (rollingVal + t + column + row) % [outputChars count];
  28.             NSString *s = [NSString stringWithFormat:@"%@",[outputChars objectAtIndex:outPutIndex]];
  29.             UIButton *button = (UIButton*)[self.MainView viewWithTag:t++];
  30.             [button setTitle:s forState:UIControlStateNormal];
  31.             NSLog(@"rollingVal: %lu outPut: %lu v: %@", rollingVal, outPutIndex, s);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement