Skip to content

Commit

Permalink
Merge pull request #27 from clickalicious/develop
Browse files Browse the repository at this point in the history
Release 3.0.0 preparations.
  • Loading branch information
benjamin-carl committed Apr 30, 2017
2 parents 00164e9 + 3105f87 commit 9ee48ac
Show file tree
Hide file tree
Showing 24 changed files with 156 additions and 301 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
* eol=lf text=auto
*.java eol=lf text ident diff=java
*.c eol=lf text ident diff=cpp
*.h eol=lf text ident diff=cpp
Expand All @@ -25,4 +24,4 @@
*.tar binary
*.dll binary
*.exe binary
*.zip binary
*.zip binary
17 changes: 2 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
# Project specific
# clickalicious
__*/
docs/coverage/*
build/*
bin/*

# Common
*.bak
*.tmp
*.log
*.old
.settings
.buildpath
.project
.externalToolBuilders

# Composer
vendor/
composer.lock

# Node & npm
npm_modules/
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ php:
- 5.6
- 7.0
- 7.1
- nightly
- hhvm

sudo: false

matrix:
allow_failures:
- php: hhvm
- php: 5.3
- php: 5.4
- php: 5.5
- php: nightly
fast_finish: true

before_install:
Expand All @@ -22,38 +26,37 @@ env:
- PREFER_LOWEST=""

before_script:
- composer update --prefer-dist $PREFER_LOWEST
- composer update --ignore-platform-reqs --prefer-dist $PREFER_LOWEST
- composer --optimize-autoloader --no-interaction

script:
- bin/phpunit --configuration . --coverage-clover=build/logs/clover.xml --coverage-html=build/html/coverage

after_script:
# We upload only for reference platform! This is our base for further code analyses and so on.
- if [ $(phpenv version-name) == "5.6" ] && [ "$PREFER_LOWEST" == "--prefer-lowest" ]; then bin/codacycoverage clover build/logs/clover.xml; fi
- if [ $(phpenv version-name) == "5.6" ] && [ "$PREFER_LOWEST" == "--prefer-lowest" ]; then bin/codacycoverage clover build/logs/clover.xml > /dev/null 2>&1; fi

after_success:
# Push coverage to github pages branch
- chmod +x ./update-gh-pages.sh
- if [ $(phpenv version-name) == "5.4" ] && [ "$PREFER_LOWEST" == "--prefer-lowest" ]; then bash ./update-gh-pages.sh; fi
- if [ $(phpenv version-name) == "5.6" ] && [ "$PREFER_LOWEST" == "--prefer-lowest" ]; then bash ./update-gh-pages.sh; fi
# CREATE GIT TAG
- git config --global user.email "[email protected]"
- git config --global user.name "Travis"
- export GIT_TAG=build-$TRAVIS_BRANCH-$(date -u "+%Y-%m-%d")-$TRAVIS_BUILD_NUMBER
- echo -n $GIT_TAG > public/version
- git commit -m "Set build VERSION number" public/version
- git tag $GIT_TAG -a -m "Generated tag from TravisCI build $TRAVIS_BUILD_NUMBER"
- git push --tags --quiet https://[email protected]/clickalicious/Rng > /dev/null 2>&1
- git push --tags --quiet https://[email protected]/clickalicious/rng > /dev/null 2>&1

# blacklist
# Blacklist the pushed tag from above to prevent black hole
branches:
except:
- /^build-[0-9a-z\-]*/

# Who to notify?
notifications:
slack:
secure: "a9zWeVc7lcZy1bKrtnYl/kvKgFKdifJdZL1nrk1zy+xv0VmXirFgp+pWMa97Ysnhh2mOQhwCnRUtucahMdjw+ABabeb8LSDP28Y0i9PJNLwjGLsT8W1wbtfqQuiJ/h5zEYNiHri9mfs1ksuCut8v6c3/LtEpGWyS0E05XV+S1v4="
secure: fNU5MckS6fgDKhMeFPC0D0Qj7anIHQP7DlPf+WzDePbC7QXZWMiIR9QGY5T5VKxuezwVQZVZzUAYdlBSJE0WN18v3S2ulxvY1ZuWK9NeGsA5giuBVaamHlQzBkFqHk5i9L0hJ0WAsoPp4RqLzWp/y+w8fBxeNEywEttEqMk5Wx4=
email:
recipients:
- [email protected]
4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
rng

(The MIT license)
Copyright 2017 clickalicious UG, Benjamin Carl
Copyright 2017 clickalicious, Benjamin Carl

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<img src="https://avatars0.githubusercontent.com/u/26927954?v=3&s=140" align="right" />
<img src="https://avatars0.githubusercontent.com/u/26927954?v=3&s=80" align="right" />

---

![Logo of rng](docs/logo-large.png)

The secure **Pseudo Random Number Generator** `PRNG` for PHP.

| [![Build Status](https://travis-ci.org/clickalicious/rng.svg?branch=master)](https://travis-ci.org/clickalicious/rng) | [![Codacy branch grade](https://img.shields.io/codacy/grade/f53e4682e6524d44aedb454adce68a18/master.svg)](https://www.codacy.com/app/clickalicious/rng?utm_source=github.com&utm_medium=referral&utm_content=clickalicious/rng&utm_campaign=Badge_Grade) | [![Codacy coverage](https://img.shields.io/codacy/coverage/f53e4682e6524d44aedb454adce68a18.svg)](https://www.codacy.com/app/clickalicious/rng?utm_source=github.com&utm_medium=referral&utm_content=clickalicious/rng&utm_campaign=Badge_Grade) | [![clickalicious open source](https://img.shields.io/badge/clickalicious-open--source-green.svg?style=flat)](https://www.clickalicious.de/) |
| [![Build Status](https://travis-ci.org/clickalicious/rng.svg?branch=master)](https://travis-ci.org/clickalicious/rng) | [![Codacy branch grade](https://img.shields.io/codacy/grade/f53e4682e6524d44aedb454adce68a18/master.svg)](https://www.codacy.com/app/clickalicious/rng?utm_source=github.com&utm_medium=referral&utm_content=clickalicious/rng&utm_campaign=Badge_Grade) | [![Codacy coverage](https://img.shields.io/codacy/coverage/f53e4682e6524d44aedb454adce68a18.svg)](https://www.codacy.com/app/clickalicious/rng?utm_source=github.com&utm_medium=referral&utm_content=clickalicious/rng&utm_campaign=Badge_Grade) | [![clickalicious open source](https://img.shields.io/badge/clickalicious-open--source-green.svg?style=flat)](https://clickalicious.de/) |
|--- |--- |--- |--- |
| [![GitHub release](https://img.shields.io/github/release/clickalicious/rng.svg?style=flat)](https://github.com/clickalicious/rng/releases) | [![Waffle.io](https://img.shields.io/waffle/label/clickalicious/rng/in%20progress.svg)](https://waffle.io/clickalicious/rng) | [![Issue Stats](https://img.shields.io/issuestats/i/github/clickalicious/rng.svg)](https://github.com/clickalicious/rng/issues) | [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT) |
| [![GitHub release](https://img.shields.io/github/release/clickalicious/rng.svg?style=flat)](https://github.com/clickalicious/rng/releases) | [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT) | [![Issue Stats](https://img.shields.io/issuestats/i/github/clickalicious/rng.svg)](https://github.com/clickalicious/rng/issues) | [![Dependency Status](https://dependencyci.com/github/clickalicious/rng/badge)](https://dependencyci.com/github/clickalicious/rng) |


## Table of Contents
Expand All @@ -25,11 +25,10 @@ The secure **Pseudo Random Number Generator** `PRNG` for PHP.

## Features

- Provides a secure `PRNG`: pseudo random number generator (64-Bit support)
- OOP facade to PHP core functionality
- High performance (developed using a profiler)
- Lightweight and high-quality codebase (following PSR standards e.g. `PSR-1,2,4`)
- Secure `PRNG` implementation (64-Bit support)
- OOP facade to PHP core functionality
- PHP > `5.6` up to `7.2` & `HHVM` ready
- Stable, clean + well documented code
- Unit-tested with a good coverage

Expand All @@ -38,34 +37,34 @@ The secure **Pseudo Random Number Generator** `PRNG` for PHP.

Generate `random number` between 1 and 10 using `OPEN_SSL` random bytes (library default):
```php
$generator = new Rng\Generator();
$generator = new \Clickalicious\Rng\Generator();
$number = $generator->generate(1, 10);
echo $number;
```

Generate `random number` between 1 and 10 using `PHP_MERSENNE_TWISTER` random bytes:
```php
$generator = new Rng\Generator(Rng\Generator::MODE_PHP_MERSENNE_TWISTER);
$generator = new \Clickalicious\Rng\Generator(\Clickalicious\Rng\Generator::MODE_PHP_MERSENNE_TWISTER);
$number = $generator->generate(1, 10);
echo $number;
```

Generate `16 random bytes` using `MODE_OPEN_SSL` random bytes (library default):
```php
$generator = new Rng\Generator();
$generator = new \Clickalicious\Rng\Generator();
$bytes = $generator->getRandomBytes(16);
```

Generate `32 random bytes` using `NATIVE-PHP` random bytes:
```php
$generator = new Rng\Generator();
$generator = new \Clickalicious\Rng\Generator();
$bytes = $generator->getRandomBytes(32);
```


### Visualization

You can create a visualization of randomization (as you can see below but larger size) through [`visual.php` »](visual.php) (the file is located in root).
You can create a visualization of randomization (as you can see below but larger size) through [`visual.php` »](visual.php) (the file is located in root). As you may see: The first square (light grey) is the default PHP random generated noise which is aligned by a pattern (you will see in the large version of the picture). The following three squares a generated using a more secure generator like Open-SSL for example.

![Logo of rng](docs/visualization.png)

Expand Down Expand Up @@ -118,4 +117,4 @@ Thanks to our sponsors and supporters:


###### Copyright
<div>Icons made by <a href="http://www.flaticon.com/authors/roundicons" title="Roundicons">Roundicons</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
<div>Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clickalicious/rng",
"description": "rng - The secure Pseudo Random Number Generator PRNG for PHP.",
"description": "The secure Pseudo Random Number Generator (PRNG) for PHP.",
"type": "library",
"authors": [
{
Expand All @@ -13,7 +13,7 @@
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=5.4.0",
"php": ">=5.6.0",
"ext-openssl": "*",
"roave/security-advisories": "dev-master as 1.0.x-dev",
"paragonie/random_compat": "^2.0"
Expand All @@ -25,12 +25,12 @@
},
"autoload": {
"psr-4": {
"Rng\\": "src/Rng/"
"Clickalicious\\Rng\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Rng\\": "tests/Rng/"
"Clickalicious\\Rng\\": "tests/"
}
},
"keywords": [
Expand All @@ -52,8 +52,8 @@
"wiki": "https://github.com/clickalicious/rng/wiki",
"tests": "https://clickalicious.github.io/rng"
},
"config" : {
"bin-dir" : "bin",
"preferred-install": "source"
"config": {
"bin-dir": "bin",
"preferred-install": "dist"
}
}
10 changes: 4 additions & 6 deletions demo.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php

/**
* rng
*
* (The MIT license)
* Copyright 2017 clickalicious UG, Benjamin Carl
* Copyright 2017 clickalicious, Benjamin Carl
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
Expand Down Expand Up @@ -34,7 +32,7 @@
* Generate a random number with best rng available
* between 1 and 10:
*/
$generator = new Rng\Generator();
$generator = new \Clickalicious\Rng\Generator();
$number = $generator->generate(1, 10);
echo $number.PHP_EOL;

Expand All @@ -44,7 +42,7 @@
* Generate a random number with PHP's default rng
* between 1 and 10:
*/
$generator = new Rng\Generator(Rng\Generator::MODE_PHP_DEFAULT);
$generator = new \Clickalicious\Rng\Generator(\Clickalicious\Rng\Generator::MODE_PHP_DEFAULT);
$number = $generator->generate(1, 10);
echo $number.PHP_EOL;

Expand All @@ -54,6 +52,6 @@
* Generate a random number with PHP's mersenne twister rng
* between 1 and 10:
*/
$generator = new Rng\Generator(Rng\Generator::MODE_PHP_MERSENNE_TWISTER);
$generator = new \Clickalicious\Rng\Generator(\Clickalicious\Rng\Generator::MODE_PHP_MERSENNE_TWISTER);
$number = $generator->generate(1, 10);
echo $number.PHP_EOL;
3 changes: 3 additions & 0 deletions docs/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
url: http://www.flaticon.com/free-icon/random-button_98711
color: #FFCC00
author: <div>Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
Binary file modified docs/logo-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logo-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logo-24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logo-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logo-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logo-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logo-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logo-large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 4 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
backupGlobals="false"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.7/phpunit.xsd"
>


<testsuites>
<testsuite name="clickalicious\rng Test Suite">
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
Expand All @@ -17,10 +14,11 @@
<directory>./src</directory>
<exclude>
<directory>./bin</directory>
<directory>./build</directory>
<directory>./docs</directory>
<directory>./vendor</directory>
<directory>./tests</directory>
<directory>./src/Rng/Autoloader.php</directory>
<directory>./demo</directory>
<directory>./src/Rng/Exception.php</directory>
</exclude>
</whitelist>
Expand Down
38 changes: 38 additions & 0 deletions src/CryptographicWeaknessException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* (The MIT license)
* Copyright 2017 clickalicious, Benjamin Carl
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

namespace Clickalicious\Rng;

/**
* Class Exception
*
* @package Rng
*/
class CryptographicWeaknessException extends \UnexpectedValueException
{
// Intentionally left empty
}
7 changes: 3 additions & 4 deletions src/Rng/Exception.php → src/Exception.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php

/**
* rng
*
* (The MIT license)
* Copyright 2017 clickalicious UG, Benjamin Carl
* Copyright 2017 clickalicious, Benjamin Carl
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
Expand All @@ -26,7 +24,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Rng;

namespace Clickalicious\Rng;

/**
* Class Exception
Expand Down
Loading

0 comments on commit 9ee48ac

Please sign in to comment.