sha1 in CodeIgniter? sha1 in CodeIgniter? codeigniter codeigniter

sha1 in CodeIgniter?


If your PHP installation doesn't have sha1 installed, you can use the CI version. If your PHP installation already has it, you don't need to use the CI function.

From the user guide:

$this->encrypt->sha1();

SHA1 encoding function. Provide a string and it will return a 160 bit one way hash. Note: SHA1, just like MD5 is non-decodable. Example: $hash = $this->encrypt->sha1('Some string');

Many PHP installations have SHA1 support by default so if all you need is to encode a hash it's simpler to use the native function: $hash = sha1('Some string');

If your server does not support SHA1 you can use the provided function.

More info: http://codeigniter.com/user_guide/libraries/encryption.html


Pretty sure the function you show is a pure SHA encrypt - you only use a specific encryption_key if you want to key/encode the data so only you (the holder of the encryption key), will be able to decrypt it.

$encrypted_with_encryption_key = $this->encrypt->encode($var);$encrypted_with_sha_no_enc_key = $this->encrypt->sha1($var);


the encryption key is saved at config/config.phpas

$config['encryption_key'] = 'some key';