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 8290661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:52:23+00:00 2026-06-08T12:52:23+00:00

How do I store some encrypted strings (just about one to a couple of

  • 0

How do I store some encrypted strings (just about one to a couple of words)?

Let’s suppose I encrypted this string:

$key='fappings'; // Encryption Key
$str='Mama Luigi'; // String that I Encrypted
$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $str, MCRYPT_MODE_CBC, md5(md5($key)));

Now, assuming I don’t want to index that data, or perform any searches on it, just wanna ask two questions:

  1. What datatype would I better use? I would guess varbinary, but I’m not sure…

  2. How would I make process my query? Assuming I would use a simple mysql_query() function.

I saw some people would actually make base64 encode, and then simply insert it, just the way a normal string would go, eg:

mysql_query("insert into faps data='".base64_encode($encrypted)."'");

But something tells me it’s not the way to do it. Even space-wise insufficient.

What would be a better approach?

  • 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-08T12:52:26+00:00Added an answer on June 8, 2026 at 12:52 pm

    Use a varbinary (as you suggest) or a blob, depending on length required. For safety, multiply the length of the string by 4.

    No need to base64 encode it – that just adds yet more length. All you need are the regular escaping functions (mysql_real_escape_string at a basic level, or bind using PDO and it’ll make it safe for you).

    An alternative may be to use MySql’s own encryption functions. http://dev.mysql.com/doc//refman/5.5/en/encryption-functions.html as this may save you some programming hassles? Moves the stress from PHP server to MySQL server – so consider which is less stressed, and whether travelling of the uncompressed SQL instructions over an open network matters etc.

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

Sidebar

Related Questions

I have some encrypted NSString store in a transformable field. I need to decrypt
I want to temporary store some mapping data. The mapping is one to one.
I'm attempting to use symmetric encryption to encrypt some data, and store the key
I'm trying to store some encrypted (short) information in a cookie. I'm generating a
Yeah... just thinking about it... Should I store credit card numbers that have been
Let's assume I must store user's sensitive data, which was optionally encrypted on the
I need to store a password as an encrypted string in an XML file,
I want to store profile details encrypted within a database. However, some details should
I store some data as XML and the changes of the user as diff
I store some data in a database and I read those data with a

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.