PHPackages                             crecket/secure-functions - 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. [Security](/categories/security)
4. /
5. crecket/secure-functions

ActiveLibrary[Security](/categories/security)

crecket/secure-functions
========================

Secure-functions makes it easier to secure functionality

1.4(10y ago)21561WTFPLPHPPHP &gt;=5.6.0

Since Dec 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Crecket/secure-functions)[ Packagist](https://packagist.org/packages/crecket/secure-functions)[ RSS](/packages/crecket-secure-functions/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (8)DependenciesVersions (9)Used By (1)

secure-functions
================

[](#secure-functions)

[![Latest Stable Version](https://camo.githubusercontent.com/779abb510fa99e8b94d5ac532e2bbcde7b08ec4427dc8b18e2a106002fbf9147/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f637265636b65742f7365637572652d66756e6374696f6e732e737667)](https://packagist.org/packages/crecket/secure-functions)[![Build Status](https://camo.githubusercontent.com/2b1534c80037953592203ab360c7b2d66afd848904ad3ce0832654cb22cc5ed7/68747470733a2f2f7472617669732d63692e6f72672f437265636b65742f7365637572652d66756e6374696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Crecket/secure-functions)

A collection of functions which can be used for security purposes.

Instalation
-----------

[](#instalation)

#### Composer

[](#composer)

Install through composer and require the autoloader.

`composer require crecket/secure-functions`

#### Manual

[](#manual)

Download the files and require them in your project.

`require '/secure-functions/src/SecureFuncs.php';`

Scrypt and Encryption
---------------------

[](#scrypt-and-encryption)

#### [domBlack/php-scrypt](https://github.com/DomBlack/php-scrypt)

[](#domblackphp-scrypt)

Install the php module if you want to use scrypt hashing

Usage
-----

[](#usage)

All functions are static public functions right now so you can simply call the functions like this:

`SecureFuncs\SecureFuncs::password_hash('input');`

Functions
---------

[](#functions)

### compareStrings($string1, $string2)

[](#comparestringsstring1-string2)

Compare strings while preventing timed attacks

### getFormToken('form\_token\_id', $form\_token, $limit = 300)

[](#getformtokenform_token_id-form_token-limit--300)

Verify a form token for the given id. The $limit is optional andm ust be given in seconds, if the limit is 300 and the token is used after 300 seconds it will be considered invalid.

### password\_hash($password)

[](#password_hashpassword)

Hash the given password. This function allows for longer passwords and isn't affected by the null-byte issue.

### password\_verify($password, $hash)

[](#password_verifypassword-hash)

Verify the given password hash

### randomHex($length)

[](#randomhexlength)

Returns a random hexadecimal number for the given length

### randomInt($min, $max)

[](#randomintmin-max)

Returns the a secure random integer within the given range.

### randomString($length)

[](#randomstringlength)

Returns a random string for the given length

### scryptcheck($password, $hash)

[](#scryptcheckpassword-hash)

Compare a password and hash using [DomBlack/php-scrypt](https://github.com/DomBlack/php-scrypt)

### scrypthash($password, $salt, $cpu, $memory, $parallel)

[](#scrypthashpassword-salt-cpu-memory-parallel)

Hash a password using DomBlack's php scrypt library

### setFormToken($id)

[](#setformtokenid)

Set a unique token in the session and returns it, can be used to verify post/get requests

### strlen($str)

[](#strlenstr)

Returns the length of the given string using mb\_strlen when available

### pseudoBytes($length)

[](#pseudobyteslength)

Returns random bytes for the given length

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~14 days

Recently: every ~20 days

Total

8

Last Release

3780d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce40a957cded3417a986fc49971e429eafbf3ead0a2c8e23433b61fa360b22e8?d=identicon)[Crecket](/maintainers/Crecket)

---

Top Contributors

[![Crecket](https://avatars.githubusercontent.com/u/7481136?v=4)](https://github.com/Crecket "Crecket (17 commits)")

---

Tags

bcrypthashphp-scryptrandom-bytesverify

### Embed Badge

![Health badge](/badges/crecket-secure-functions/health.svg)

```
[![Health](https://phpackages.com/badges/crecket-secure-functions/health.svg)](https://phpackages.com/packages/crecket-secure-functions)
```

###  Alternatives

[paragonie/ecc

PHP Elliptic Curve Cryptography library

25866.3k44](/packages/paragonie-ecc)[sansec/magento2-module-shield

15218.6k](/packages/sansec-magento2-module-shield)[dwgebler/encryption

Encryption wrapper for PHP using libsodium — simple API for symmetric and asymmetric encryption, password hashing, digital signing, and message authentication.

317.5k](/packages/dwgebler-encryption)

PHPackages © 2026

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