CodeIgniter Forums
Introducing RandGen, CodeIgniter library for... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: Introducing RandGen, CodeIgniter library for... (/showthread.php?tid=66133)



Introducing RandGen, CodeIgniter library for... - DanielTheGeek - 09-10-2016

Hello everyone, RandGen is a small lightweight CodeIgniter library for generating random strings.

Requirements
  • PHP >=5.2.4
Dependencies
  • None
Download|Contribute|View documentation => on Github

Usage sample:
PHP Code:
<?php
 
class My_Class extends CI_Controller {
    public function 
index() {
      
// Load the library
      
$this->load->library('rand-gen');
    
      
// Random string of 100 characters using the default combination
 
     $randString $this->rand_gen->generate(100);
 
     echo $randString;

 
     // Random string of 30 characters containing only alphabets
 
     $randAlphaString $this->rand_gen->generate(30'alpha');
 
     echo $randAlphaString;

 
     // Random string of 250 characters containing only numbers
 
     $randNumString $this->rand_gen->generate(250'numeric');
 
     echo $randNumString;

 
     // Random string of 50 characters containing only alphabets and numbers
 
     $randAlphanumString $this->rand_gen->generate(50'alpha-numeric');
 
     echo $randAlphanumString
  }
}
?>



RE: Introducing RandGen, CodeIgniter library for... - Wouter60 - 09-11-2016

CI has the random_string() function inside the string helper. What are the benefits of this library compared to that?