PHPackages                             magadanuhak/laravel-provably-fair - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. magadanuhak/laravel-provably-fair

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

magadanuhak/laravel-provably-fair
=================================

A Laravel package to get Provably Fair random numbers that user can verify

1.0.5(1y ago)22.2kMITPHPPHP &gt;=8.0

Since Jul 14Pushed 1y ago2 watchersCompare

[ Source](https://github.com/magadanuhak/laravel-provably-fair)[ Packagist](https://packagist.org/packages/magadanuhak/laravel-provably-fair)[ RSS](/packages/magadanuhak-laravel-provably-fair/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

magadanuhak/laravel-provably-fair
=================================

[](#magadanuhaklaravel-provably-fair)

Laravel ProvablyFair is a package that permits to generate random numbers using clientSeed - a string from frontend and serverSeed - a string from backend.

[![Total Downloads](https://camo.githubusercontent.com/61cf6b17df69d7bad0fb5f4024aaeca3dc228c922665f42ed2e2eb880120fe13/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61676164616e7568616b2f6c61726176656c2d70726f7661626c792d66616972)](https://packagist.org/packages/magadanuhak/laravel-provably-fair)[![Latest Stable Version](https://camo.githubusercontent.com/f509483d5c7686f82d059f8d8467b63bb612430d591d67b8e9943391e61818fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61676164616e7568616b2f6c61726176656c2d70726f7661626c792d66616972)](https://packagist.org/packages/magadanuhak/laravel-provably-fair)[![License](https://camo.githubusercontent.com/bc43dde42bbd2e1a132d461491cac9569ba63d5de4b1664eedb9b886c7a2dbd5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d61676164616e7568616b2f6c61726176656c2d70726f7661626c792d66616972)](https://packagist.org/packages/magadanuhak/laravel-provably-fair)

If you know clientSeed, serverSeed and nonce you can generate the same random number. Nonce is a countable number that is used to count how much times the same clientSeed and serverSeed was used.

Installation
------------

[](#installation)

Use the composer package manager [composer](https://getcomposer.org/download/) to install package.

```
composer require magadanuhak/laravel-provably-fair
```

Usage

```
    $provablyFairService = new ProvablyFair(); //Initialization of provably fair
    $clientSeed = $request->client_seed; // Client seed is a string that you should get from frontend
    $resultedData = $provablyFairService->getRandomNumber($clientSeed); // This method will return an object ProvablyFairResultData
```

Result of `getRandomNumber($clientSeed);` will be

```
class ProvablyFairResultData
{
    public function __construct(
        public readonly string $clientSeed,
        public readonly string $serverSeed,
        public readonly int    $nonce,
        public readonly float  $resultedNumber,
        public readonly float  $minimalValue,
        public readonly float  $maximalValue,
    )
    {
    }
}
```

Now you can store this data in database, return to the user. Here is an example of getting an item from a collection by chance

```
class GetRandomWeapon {

    public function chances(): Collection
    {
        return collect([
            "Ak-47" => 45,
            "Mp-40" => 50,
            "AWM" => 5,
        ]);
    }

    public function getItem(): string //Returns won Item Name
    {
        $sum = 0;

        $provablyFairService = new ProvablyFair(); //Initialization of provably fair
        $clientSeed = $request->client_seed; // Client seed is a string that you should get from frontend
        $resultedData = $provablyFairService->getRandomNumber($clientSeed);  // This method will return an object ProvablyFairResultData
//      $resultedData = $provablyFairService->getRandomNumber($clientSeed, $serverSeed, $nonce);  // $serverSeed, $nonce are optionally This method will return an object ProvablyFairResultData

        $choice = $resultedData->resultedNumber;

        return app(
            $this->chances()
                ->map(function ($value, $item) use (&$sum) {
                    $sum += $value;
                    return $sum;
                })
                ->reduce(function ($result, $value, $key) use ($choice) {
                    if (is_string($result)) {
                        return $result;
                    }

                    if ($choice provablyFair->getRandomNumber($clientSeed);
    }
}
```

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~79 days

Total

5

Last Release

714d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0bfbcf1717d32811e44a9cb5dd947542c13ff5fd207582cbf9c8664e60445dfe?d=identicon)[magadanuhak](/maintainers/magadanuhak)

---

Top Contributors

[![magadanuhak](https://avatars.githubusercontent.com/u/32567230?v=4)](https://github.com/magadanuhak "magadanuhak (19 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/magadanuhak-laravel-provably-fair/health.svg)

```
[![Health](https://phpackages.com/badges/magadanuhak-laravel-provably-fair/health.svg)](https://phpackages.com/packages/magadanuhak-laravel-provably-fair)
```

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
