I want to use AES_ENCRYPT in my query to insert encrypted data.
So i have write below query to convert text into encryption
SELECT AES_ENCRYPT('1234567#','testingpart') |
So i got the below output
0x9427909a49cf68afb9494b25363ab14d
But i want output like 9427909A49CF68AFB9494B25363AB14DRemove 0x and convert all character into capital.
You should use hex function
SELECT HEX(AES_ENCRYPT('1234567#','testingpart'))
Related
I've a db table with a varchar(64) field to store PHashing data, as 64 chars (1's and 0's ascii characters). I need to calculate hamming distance with a test hasta, and it seems that the most efficient way to do is using mysql bit_count function. The problem is that I haven't found any way to convert/cast/whatever the hash field in order to be interpreted as a byte(8) instead of varchar(64). Like:
> select hash from data;
"0000000101100111111100011110000011100000111100011011111110011011"
> select convert_to_binary(hash) from data;
0b0000000101100111111100011110000011100000111100011011111110011011
I cannot alter the data and convert all previous data into a binary field. Is there any way to force mysql to re-interpret a field as a literal, or any other alternative solution?
I think you should be able to use it like this:
SELECT BIT_COUNT(CAST(hash AS BINARY)) FROM data;
Use CAST to convert the field to BINARY and pass the result to BIT_COUNT. Casting the field hash to binary will turn it into a string with the binary data type, but BIT_COUNT is able to handle that.
Working code:
SELECT BIT_COUNT( CONV( hash, 2, 10 ) ^
0b0000000101100111111100011110000011100000111100011011111110011011 )
I know a little SQL injection about php and i read some posts about sqli!the posts say when hackers want to get the column names of a table,they will use
select group_concat(column_name) from information_schema.columns where table_name=0x7573657273
in the statement "0x7573657273" is the hex string of "users".surprisingly,when I execute this statement in mysql console,it will exactly return the colunms of table users.
does it mean mysql will automately convert hex to string,eg convert "0x7573657273" to "uses" or convert "0x3D" to "="?
does it mean mysql can understand what the hex means?
In string contexts, MySQL treats hexadecimal values as binary strings, where each pair of hex digits is converted to a character.
Refer link: http://dev.mysql.com/doc/refman/5.0/en/hexadecimal-literals.html
Good Day,
I am trying to get a point from an SQL column. CUrrently it is encoded as a string of characters: Gþ`C#Ëóàî¬Ë]À
So is there any way to actually decode it to get the actual value?
Use MySQL's AsText() function:
SELECT AsText(myPoint) FROM myTable
I need to find part of string which is stored in a varbinary field on SQL Server 2008. The data that is stored in the field is in HEX Binary.
For example the field has 0xA0000000001A000000000000000000000000000000000000000000000000000000850000002416002F002A002000480065006C006C006F0020002A002F0007
I can ignore the first 37 characters. When I look at this in a SQL application it reads as follows after the first 37 characters
/..H.e.l.l.o../
I know that the hex binary is stored in Unicode format.
My question is how can i search for the word 'Hello' using a SQL Statement.
I tried the following below but i do not get any results
SELECT CONVERT(varchar(max),fieldname) from tablename where fieldname like '%Hello%;
I would really appreciate any help that I can get
Thanks
If the binary value is in a Unicode encoding, you will need to cast it to NVARCHAR, and also use a Unicode string literal for the search value:
SELECT CONVERT(nvarchar(max),fieldname) from tablename where fieldname like N'%Hello%';
i'd like to update a table field in my mysql data base and convert all links to lowercase, e.g.
to convert:
http://www.domamain.com/MyLinks/News/FileName.html
to
http://www.domamain.com/mylinks/news/filename.html
Can this be done?
Thanks
You can convert an entire column to lowercase with the LOWER() function
UPDATE mytable
SET url = LOWER(url)
It seems that you can't do regular expression replace in MYSQL though:
How to do a regular expression replace in MySQL?