Jump to content

Featured Replies

Posted

Hi

I have a plugin that uses the IPS\Text\Encrypt class descrypt and encrypt methods to store client login data. After moving to a new server the data can no longer be decrypted. Is is possible to transfer the encryption key to the new server to allow this to continue working?

Thanks

Solved by Stuart Silvester

Go to solution

If you moved to another host you probably changed your sql database details. So, look:

	/**
	 * Get Key
	 *
	 * @return	void
	 */
	public static function key()
	{
		return \IPS\TEXT_ENCRYPTION_KEY ?: md5( \IPS\Settings::i()->sql_pass . \IPS\Settings::i()->sql_database );
	}

It won't work due to this.

  • Author

Thanks!

Wait... so encrypted data ceases to be accessible if you do something standard like rotate service account passwords? 😵

Why isn't there a constant that's used as an encryption key just for this purpose so that the password can be changed without affecting anything else?

  • Solution
Just now, Paul E. said:

Wait... so encrypted data ceases to be accessible if you do something standard like rotate service account passwords? 😵

Why isn't there a constant that's used as an encryption key just for this purpose so that the password can be changed without affecting anything else?

There is a constant ( TEXT_ENCRYPTION_KEY ) that you can set if you change your credentials. If you already have encrypted text stored, you would need to calculate the same MD5 and then save it to constants.php

  • Author

That's great news. Since I didn't know that, I actually created a hook to override the key method 😉 

Why? I showed it already ?: 

  • Author

You are right, but it wasn't clear to me straightaway from the code you shared. Should have taken a few more minutes to read it 😉 

Recently Browsing 0

  • No registered users viewing this page.