How to Decrypt a key value data stored in mySQL database? - mysql

I have data in mySQL database table as "2888f3f0-286a-11db-954d-b1740a14150f".
I am not sure how to decrypt it or get the actual text for this value.

First of all, check the algorithm/function through which it got encrypted and ultimately you will be able to decrypt the code IF decryption function is available
otherwise, you can't get the text from this text

Related

Mysql encryption/decryption without sending password in query

I need to encrypt some specific columns in mysql database. I researched and found few ways like AES_ENCRYPT functions, but these solutions requires sending the key value in the query.
I am looking for a solution where password can be stored in database some location and mysql can automatically use that value to encyrpt or decrypt that particular column?
Thank you.

Trying to put too much data into mysql TEXT data type

Let's say that I have a html form (actually I have an editor - TinyMCE) which through PHP inserts a bunch of text into Mysql table.
I want to know the following:
If I have TINYTEXT data type in Mysql column - what happens if the user tries to put more text than 255 bytes into Mysql table??
Does the application save first 255 bytes and "cuts off" the rest? Or does nothing get saved into Mysql table and mysql issues a warning?? Or none of the above?
Actually, what I want and intend to do is the following:
Limit the size of user form input by setting the column data type in Mysql to TEXT data type, which can hold maximum of 64 KB of text. I want to limit the amount of text that gets passed from user to database, so that user can't put too much data to the server at once.
So, basically, I want to know what happens, if the user puts more text through TinyMCE editor than 65535 bytes, assuming TEXT data type in mysql table.
MySQL, by default, truncates the data if it's too long, and sends a warning.
SHOW WARNINGS;
Data truncated for foo ..
Just to be clear: the data will be saved, but you will be missing the part that was too large.
Default mysql configuration truncate the data if the value is greater than the maximum table field definition size, this will produce a non blocking warning.
If you want a blocking error you have to set the sql_mode to STRICT_ALL_TABLES
dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_all_tables
IMHO the best way is to manage this error via applicatin software.
Hope this helps
If you enter too much data to a TEXT field in MySQL it will insert the row anyway but with that field truncated to the maximum length, and issue a warning.
Even if MySQL did prevent the row from being added it would not be a good way of limiting the length of data that a user can enter. You should check the length of the POSTed string in PHP, and not run the query at all if it is too long - and perhaps tell the user why their data wasn't entered.
As well as this you can prevent the user from entering too many characters at the client side (although you should always do the check server side as well because someone could bypass the client side limit). It appears that there is no built-in way of doing this in TinyMCE, but it is possible by writing a callback: Limit the number of character in tinyMCE

can i decrypt the data using SHA 5 in MySQL?

I am trying to encrypt and decrypt the data using SHA 5 in mysql. I am able to encrypt the data but unable to decrypt it. How can I achieve the decrption of SHA5 encrypted data in mysql.
What do you exactly want to do ? As Michael says, you will not be able to reverse a hash. We use hash when we want hide the real information and never decrypt it. If you want to decrypt it, then use an inversible function.
Hash algorithms (SHA = secure hash algorithm) are one way. You can use then to verify information such as a password by checking that the password entered, when SHA'd, equals the encrypted version on record. You can't decrypt with it though.

MySQL Column for Encryption

I need to build a small private app. I want to store a piece of personally identifiable information (it's an internal account number -- not an SSN or anything like super-sensitive) in a table that "encrypts" it.
I put encrypts in quotes because I wish the data to be stored as follows:
stored in a way that if someone physically looked at the table data the piece of info would not be discernible
stored in a way that if someone did a simple query select the resulting data output would not not be discernible
yet when I write my own query select statement I can still decrypt the data and present it in a readable fashion
In other words, I want it only moderately encrypted so that I can still decrypt it and read it. I know MD5 hashing locks the value from ever being read. I want something less than that.
Thanks
MD5 is NOT encryption. It's hashing.
If you don't mind passing the crypt key around in each query, it's trivial to have this in MySQL:
SELECT AES_DECRYPT(crypted_field, 'crypt key goes here') AS decrypted
and
INSERT INTO yourtable (crypted) VALUES (AES_ENCRYPT('some string', 'crypt key'));
I think what you're looking for is "Symmetric Key Encryption". You can use a key to encrypt your data, and the same key to decrypt it as needed (as opposed to a hash function which as you said - makes the original data irrecoverable). In MySQL I would take a look at the AES_Encrypt and AES_Decrypt functions.. Hopefully that gets you pointed in the right direction!
MySQL provides both DES and AES encryption. You will need to figure out key management, but the encryption algorithms are available.

MySQL chops off characters from md5 password

I'm developing a website locally using XAMPP. There is a registration page in which I save the password, after encrypting it with MD5, to a MySQL database. The problem is that when I try to log in, I'm unable to. I discovered that the password was the problem. I checked the database and compared the MD5-ed password with the one I logged in with (I just echoed the MD5 hash of the password onto the page to compare). I found that the one in the database was shorter than the one echoed. My conclusion was that MySQL was chopping off some characters at the end of the hash. What should I do? I know it has to do with some settings on MySQL but I need help.
As at now, I have to use substr function on the hash in the registration and login processes so as to be able to log in.
If the column length is causing the problem, alter the column to accept a longer length. MD5's are always 32 hex digits, so VARCHAR(32) would be a good option.
It depends by the length of the value in the database ... check your field in the database and verify that his type is atleast something like a varchar(32)
To fix it you can use a query like that
ALTER TABLE Example
MODIFY password varchar(32)
or use the phpMyAdmin interface