0

I'm building a quick site with CodeIgniter and currently I'm making use of the CI 'encrypt' library. Reading through here it sounds like I just throw on a quick:

$this->encrypt->encode($secret_data);

and do this when you want to use it:

$this->encrypt->decode($encripted_string);

Then the magic of CI and Mcrypt do the rest.

Well I'm not sure I can sleep without knowing what is going on in the background. So I have two questions...

  1. How is this working? Or is there a good resource to explain to me how this is working that I can read up on it?

  2. Is this generally thought of as a safe way to encrypt data? If not where else should I be looking.

3
  • 1
    The CodeIgniter Encryption Class provides two-way keyed encoding using XOR Hashing and Mcrypt. Check in system -> libraries for the encrypt.php file and descover what the class does.... Commented Mar 22, 2016 at 18:44
  • The best resource that explains how its working is the source (old and new). It is code with small bite size (easy to understand) and documented functions. Commented Mar 22, 2016 at 20:44
  • Question 1 is off-topic, because you're asking for an off-site resource. Question 2 is somewhat opinion-based. You would need to define your security margin for question 2. Commented Mar 22, 2016 at 20:46

2 Answers 2

5

You're reading the "wrong" thing ...

The CodeIgniter documentation on EllisLab's website is outdated and no longer the official one. It's also for CodeIgniter 2.x, which is itself no longer supported.

The official documentation is on codeigniter.com, and you should be using CodeIgniter 3.x, which deprecates that old CI_Encrypt library and replaces it with a new one, which is far better and more well-documented, here:

http://www.codeigniter.com/userguide3/libraries/encryption.html

Sign up to request clarification or add additional context in comments.

1 Comment

Great point. Based on what I read, I may upgrade it from CI 2 to 3.
1

1. How is it working:

codeigniter 2.x

The CodeIgniter Encryption Class provides a two-way keyed encoding using XOR Hashing and Mcrypt.

interesting about XOR Hashing: https://stackoverflow.com/a/27952689/2275490

the php manual about Mcrypt: http://php.net/manual/en/book.mcrypt.php

Also you might want to check in system->libraries for the encrypt.php file and discover what it does.

codeigniter 3.x

Provides two-way keyed encoding using Mcrypt

the php manual about Mcrypt: http://php.net/manual/en/book.mcrypt.php the CI manual: http://www.codeigniter.com/userguide3/libraries/encryption.html

2. thought as safe way to encrypt data:

that's opinion based, I think definitely yes for a "quick site"

2 Comments

Thanks for being willing to delve into opinion. I know asking for it is a risky proposition, but sometimes it's useful to get other's opinions.
No, CI_Encrypt uses AES through Mcrypt by default. There is no "XOR Hashing" going on in there (yes, there is key hashing with XOR, but is not like the answer you linked to).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.