Code Search for Developers
 
 
  

AppController.m from redshed at Krugle


Show AppController.m syntax highlighted

#import "AppController.h"
#include <openssl/rand.h>

char* getDiceWd(int n); // I did not name this function. I have taste.

@implementation AppController

- (void)awakeFromNib {
	[self rollAgainAction:nil];
}

- (IBAction)rollAgainAction:(id)sender_ {
	NSMutableString *output = [NSMutableString string];
	
	for (unsigned lineIndex = 0, lineCount = 19; lineIndex < lineCount; lineIndex++) {
		uint16_t random[5];
		int isRandom = RAND_bytes((uint8_t*)&random, sizeof(random));
		if (isRandom) {
			[output appendFormat:[NSString stringWithFormat:@"%s %s %s %s %s\n",
				getDiceWd(random[0]),
				getDiceWd(random[1]),
				getDiceWd(random[2]),
				getDiceWd(random[3]),
				getDiceWd(random[4])]];
		} else {
			[output appendString:@"<not enough entropy>\n"];
		}
	}
	[output deleteCharactersInRange:NSMakeRange([output length]-1,1)];
	[outputView setString:output];
}

@end




See more files for this project here

redshed

Code for Mac+WebObjects.

Project homepage: http://sourceforge.net/projects/redshed
Programming language(s): C,Java,Objective C
License: other

  Diceware.xcodeproj/
    project.pbxproj
    wolf.mode1
    wolf.pbxuser
  English.lproj/
    MainMenu.nib/
      classes.nib
      info.nib
      keyedobjects.nib
    InfoPlist.strings
  AppController.h
  AppController.m
  Diceware_Prefix.pch
  Info.plist
  diceware8k.c
  main.m