PHP Classes

How to Use a PHP String Check Class to Verify If it Is a Good Random String Using the Package Random String Checker: Evaluate if random strings match given criteria

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-03-16 (2 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
randomstringchecker 1.0MIT/X Consortium ...5PHP 5, Text processing, Validation
Description 

Author

This package can evaluate if random strings match given criteria.

It provides a class that can take a string and evaluate it according to several criteria.

Currently, it can evaluate if the string:

- Has at least the minimum length

- Has letters and digits

- Has consecutive characters that are next to each other in alphabetic order

The class can return a string to tell the criteria that the string does not satisfy, or true if all criteria are satisfied.

Picture of Roberto Aleman
  Performance   Level  
Name: Roberto Aleman <contact>
Classes: 22 packages by
Country: Venezuela Venezuela
Innovation award
Innovation award
Nominee: 12x

Winner: 1x

Instructions

The code includes examples of how to create instances of the RandomStringChecker class and check various strings.

It demonstrates different scenarios, including strings that are not random due to length, repetitive patterns, or sequences.

Example

<?php
/* Author: Roberto Aleman Web: ventics.com , license: MIT */
echo "Author: Roberto Aleman, Web: ventics.com.<br/><hr>";
echo
"<h2>RandomStringChecker is designed to evaluate whether a given string is random based on specific criteria. </h2><br/><hr>";
include (
"RandomStringChecker.php");
echo
"Tip:Please read the readme file for more information on how to use it.<br/><hr>";
// Example usage

echo "<b>Example usage.</b><br/><hr>";
$string1 = new RandomStringChecker("123456789");
echo
$string1->report() . "<br/>";

$string2 = new RandomStringChecker("0105070903");
echo
$string2->report() . "<br/>";

$string3 = new RandomStringChecker("%********MEuAy3gCVZ3LYGj5^FeCi");
echo
$string3->report() . "<br/>";

$string4 = new RandomStringChecker("demoadmin");
echo
$string4->report() . "<br/>";

$string5 = new RandomStringChecker("A1b2C3d4$");
echo
$string5->report() . "<br/>";

$string6 = new RandomStringChecker("abcdefg123$");
echo
$string6->report() . "<br/>"; // Example of ascending sequence

$string7 = new RandomStringChecker("987654321$");
echo
$string7->report() . "<br/>"; // Example of descending sequence

?>


Details

RandomStringChecker

RandomStringChecker, Designed to evaluate whether a given string is random according to specific criteria.

Author: <b>Roberto Aleman</b><br/> Web: <b><a href="https://ventics.com">ventics.com</a></b><br/> License: <b>MIT</b><br/> Created: <b>March 16, 2025</b><br/>

<span class="">The provided PHP code defines a class called <code translate="no">RandomStringChecker</code>, which is designed to evaluate whether a given string is random based on specific criteria. Here?s a breakdown of what the code does:</span> <ol class=""> <li class=""><span class=""><strong>Class Definition</strong>: The <code translate="no">RandomStringChecker</code> class is initialized with a string that you want to check for randomness.</span></li> <li class=""><span class=""><strong>Randomness Check</strong>: The main method, <code translate="no">isRandom()</code>, performs several checks on the string:</span> <ul class=""> <li class=""><strong>Length Check</strong>: It first checks if the string has at least 10 characters. If not, it returns a message indicating that the string is not random due to insufficient length.</li> <li class=""><strong>Character Diversity Check</strong>: It verifies that the string contains a mix of letters (both uppercase and lowercase), numbers, and special characters. If the string lacks this diversity, it returns a message stating that the string is not random.</li> <li class=""><strong>Repetitive Patterns Check</strong>: The method checks for repetitive patterns within the string. If it finds any character repeated three or more times consecutively, it concludes that the string is not random.</li> <li class=""><strong>Ascending and Descending Sequences Check</strong>: The code includes additional checks for ascending or descending sequences of characters. If such sequences are found, the string is deemed not random.</li> </ul> </li> <li class=""><span class=""><strong>Reporting Results</strong>: The <code translate="no">report()</code> method calls the <code translate="no">isRandom()</code> method and returns a message indicating whether the string is random or not, along with the reason if it is not.</span></li> <li class=""><span class=""><strong>Example Usage</strong>: The code includes examples of how to create instances of the <code translate="no">RandomStringChecker</code> class and check various strings. It demonstrates different scenarios, including strings that are not random due to length, repetitive patterns, or sequences.</span></li> </ol> <span class="">Overall, this code provides a structured way to assess the randomness of strings, making it useful for applications where random string generation is important, such as password creation or token generation.</span> <br/> <h3>Do you like the code?</h3> <p><b>Need more? Write to me and I can customize it for your project.</b></p>


  Files folder image Files (4)  
File Role Description
Plain text file example_rsc.php Example Example script
Plain text file LICENSE Lic. License text
Plain text file RandomStringChecker.php Class Class source
Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0