https://github.com/chris-huxtable/cbhrandomkit
An easier & safer to use interface for cryptographically secure random.
https://github.com/chris-huxtable/cbhrandomkit
objective-c objective-c-library random-generation random-number-generators
Last synced: 26 days ago
JSON representation
An easier & safer to use interface for cryptographically secure random.
- Host: GitHub
- URL: https://github.com/chris-huxtable/cbhrandomkit
- Owner: chris-huxtable
- License: isc
- Created: 2015-10-16T22:27:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-12-05T08:14:05.000Z (over 5 years ago)
- Last Synced: 2025-03-11T15:52:45.985Z (about 2 months ago)
- Topics: objective-c, objective-c-library, random-generation, random-number-generators
- Language: Objective-C
- Homepage:
- Size: 113 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CBHRandomKit
[](https://github.com/chris-huxtable/CBHRandomKit/releases)
[](https://cocoapods.org/pods/CBHRandomKit)
[](https://github.com/chris-huxtable/CBHRandomKit/blob/master/LICENSE)
[](https://github.com/chris-huxtable/CBHRandomKit)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`:
```objective-c
NSUInteger randInt = [CBHRandom randomUnsignedInteger];
```Generate a random `NSUInteger` less then 128 inclusive:
```objective-c
NSUInteger randInt = [CBHRandom randomUnsignedIntegerWithBound:128];
```Generate a random `NSUInteger` between 64 and 128 inclusive:
```objective-c
NSUInteger randInt = [CBHRandom randomIntegerBetweenLower:64 andUpperBound:128];
```Shuffling an Array:
```objective-c
NSArray *array = @[@1, @2, @3, @4, @5];
NSArray *shuffledArray = [array arrayByShuffling];
```Shuffling an Array in-place:
```objective-c
NSMutableArray *array = [NSMutableArray arrayWithObjects:@1, @2, @3, @4, @5, nil];
[array shuffle];
```Requesting a random object from Array:
```objective-c
NSArray *array = @[@1, @2, @3, @4, @5];
NSNumber *number = [array randomObject];
```## Licence
CBHRandomKit is available under the [ISC license](https://github.com/chris-huxtable/CBHRandomKit/blob/master/LICENSE).