CBHRandomKit 1.4.1

CBHRandomKit 1.4.1

Maintained by Chris Huxtable.



CBHRandomKit

release pod licence coverage

An easier and safer to use interface for good, cryptographically secure, random.

Use

CBHRandom provides class methods for producing random data of fixed and variable length with bounding constraints.

Example:

Generate a random NSUInteger:

NSUInteger randInt = [CBHRandom randomUnsignedInteger];

Generate a random NSUInteger less then 128 inclusive:

NSUInteger randInt = [CBHRandom randomUnsignedIntegerWithBound:128];

Generate a random NSUInteger between 64 and 128 inclusive:

NSUInteger randInt = [CBHRandom randomIntegerBetweenLower:64 andUpperBound:128];

Shuffling an Array:

NSArray *array = @[@1, @2, @3, @4, @5];
NSArray *shuffledArray = [array arrayByShuffling];

Shuffling an Array in-place:

NSMutableArray *array = [NSMutableArray arrayWithObjects:@1, @2, @3, @4, @5, nil];
[array shuffle];

Requesting a random object from Array:

NSArray *array = @[@1, @2, @3, @4, @5];
NSNumber *number = [array randomObject];

Licence

CBHRandomKit is available under the ISC license.