Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9261491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:09:34+00:00 2026-06-18T13:09:34+00:00

I found out that I should not use global variables like global $auth_key for

  • 0

I found out that I should not use global variables like global $auth_key for sensitive data’s (Correct me if that’s not true.) so I wanted to use defined variables for storing security keys.

Inside config.php salt keys are defined.

define('AUTH_KEY','::~K~UC*[tlu4Eq/]Lm|h');

define('SECURE_AUTH_KEY', 'QsTMvbV+tuU{K26!]J2');

In encryption.php contains the encryption functions where AUTH_KEY and SECURE_AUTH_KEY will be used inside.

function encrypt_text($value) {
   if(!$value) return false;
   $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, **AUTH_KEY_HERE**, $value, MCRYPT_MODE_ECB, **SECURE_AUTH_KEY_HERE**);
   return trim(base64_encode($crypttext));
}

function decrypt_text($value) {
   if(!$value) return false;
   $crypttext = base64_decode($value);
   $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, **AUTH_KEY_HERE**, $crypttext, MCRYPT_MODE_ECB, **SECURE_AUTH_KEY_HERE**);
   return trim($decrypttext);
}

Is there a way to do that? or any other solutions you can recommend? Please note that these keys are real important for encryption of sensitive informations.

Also, a another question, what is the maximum length of keys to be used on mcrypt?

Thank you and looking forward for reply of yours.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T13:09:35+00:00Added an answer on June 18, 2026 at 1:09 pm

    Using a constant is just like using a variable except there is no dollar sign.

    $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, AUTH_KEY, $value, MCRYPT_MODE_ECB, SECURE_AUTH);
    

    There is nothing inherently more secure in this approach over using the global key word. Though this approach is preferred. By using a constant you are saying this is a static value I will use across the application. Having to use global on the other hand is often just a result of bad design or laziness. It leads to code that is hard to follow, abusing what scoping tries to accomplish.

    Key length is dependent on the encryption algorithm used. RTM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found out that I can use a different theme in an C# WPF
Just found out that the video output of the iPad is not a system
I found out that in C# a+=1 is not equal to a = a+1.
After some serious googleing I found out that the RandomAccessFile-class is not thread-safe. Now
I'm not experienced with java applications but I found out that finding static pointers
Ok, just found out that using DEFAULT_GUI_FONT is the wrong thing to actually use
While setting the Canonical tag, i found out that i am not getting all
I am familiar with the fact, that i should not use dependency injection in
I found out that it is possible to open the windows explorer with a
I found out that HTML form supports only two enctype types. They are application/x-www-form-urlencoded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.