MYSQL | ENCODE () prints blob instead of text

I'm trying to encode a simple string using the ENCODE () function. Using string, it gives me text as output. But using the field gives me a BLOB. How can I bypass BLOB and output text for encoded fields?

Here's what's going on:

SELECT ENCODE('myText,'myPw')


 - Output : baddade4b04e // Goal = This + using fieldname

SELECT ENCODE(Field,'myPw') FROM myTable


 - Output : [BLOB - 14B]


What I have tried:

SELECT CAST(ENCODE(Field,'myPw') AS CHAR(1000) CHARACTER SET utf8) FROM myTable


- Output : empty lines!

SELECT CONVERT(ENCODE(Field,'myPw') USING utf8) FROM myTable


 - Exit :% (exit - 1-2 characters, cannot be right)

Let's say I have a column user

. Now I want "PaulPeter" to be encoded the same whether Im encoded the string "PaulPeter" or a field user

where the value is "PaulPeter".

Can anyone explain this to me? Thank you so much!

Encrypted string:

Encrypted string

Encrypted field:

Encrypted field

MySQL-Client-Version: 5.5.41
user

: utf8_bin text


EDIT:

I have another decryption question here: Click
After I was able to encode I got the same issue with AES_Encryption. When I encrypt a string, I get the output as a string. When encrypting a field with a string value, I get a blob. :( Completely annoying.

0


source to share


1 answer


Your custom column is of type TEXT. Try to distinguish just this column before CHAR:



SELECT AES_ENCRYPT(CAST(Field AS CHAR(1000)),'myPw') FROM myTable

      

0


source







All Articles