Monday 22 August 2016

Generating alphanumeric unique ID in codeigniter

Today i will show you how to generate alphanumeric unique ID using Codeigniter. Some times there is requirement to generate the unique id, But most of the time we are going to write our logic. But Codeigniter Framework Provides Helpers, which simplify our need. One of them is string Helper.

How to use CodeIgniter String Helper:

To use string helper you need to first load it, then use the random_string() function. Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.The first parameter specifies the type of string, the second parameter specifies the length.
The following choices are available: alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
1) alpha: A string with lower and uppercase letters only.
2) alnum: Alpha-numeric string with lower and uppercase characters.
3) numeric: Numeric string.
4) nozero: Numeric string with no zeros.
5) unique: Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type. Returns a fixed length 32 character string.
6) sha1: An encrypted random number based on do_hash() from the security helper.
That’s it

No comments:

Post a Comment

Installation of Drop Box API on Codigniter

As with the YouTube API the first step in getting this sucker setup is getting a developer key by visiting  https://www.dropbox.com/develop...