Skip to content
An easier & safer to use interface for cryptographically secure random.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CBHRandomKit.xcodeproj
CBHRandomKit
CBHRandomKitTests
.gitattributes
.gitignore
CBHRandomKit.podspec
LICENSE
README.md

README.md

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.

You can’t perform that action at this time.