0

I have a table in my data base and one of the fields is encoded by a php function. now I need to make a function to decode that field in mysql side. something like this:

SELECT permissions,decodePermission(id,permissions) as decoded_permissions FROM table

I try to use CREATE TABLE in mysql but it is very weak and in sql i don't have functions like explode(), base64_decode() , md5() (that is exists in php). so now I wanna to know it is possible to make a function in mysql from a php,c or perl file? something like this: LOAD FILE 'path/to/c/file'

3
  • I know MySQL has MD5, and I've seen implementations of explode out there. Commented Nov 13, 2012 at 14:12
  • @RocketHazmat: md5 and explode is only for examples, big problem is there is no ARRAY data type in mysql Commented Nov 13, 2012 at 14:13
  • 1
    What exactly do you want the function (or procedure) to do? You can't load arbitrary files in other languages and have MySQL run them. Commented Nov 13, 2012 at 14:14

2 Answers 2

2

Create a function via php /c isnt possible. What kind of encoding did you use? What functions?

Anyways, there are crypto functions in Mysql. have a look here https://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html

It is also not pretty secure to get the decrypted data from mysql if you are not using ssl

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

3 Comments

the encryption method is unique for my project, and it is not an standard encryption method. it encrypt strings by using an key and row id
Then its better to get the encrypted data from mysql and decrypt them in your php script. Also as i said it isnt secure to get decrypted data if you dont use ssl
my problem is my table is users table and maybe have over 10000 rows there, if I select all of them a big data must transfer between php and mysql. I am trying to make a function in mysql side and ofter that destroy functions for security :P
0

Fetch the data from MySql encrypted, using your choice of language. Ideally, you want to fetch it over a secure connection (loopback, vpn or at least SSL). Decrypt it as needed. Aim to use a standard encryption method.

Often times instead of encrypting/decrypting, a trap hash is used - results are encrypted and compared in an encrypted state. This is ideal for checking repeated phenomenon (i.e. Passwords).

Comments

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.