Forum Moderators: open

Message Too Old, No Replies

mysql encode() truncating values

It *used* to work . . . .

         

rocknbil

7:52 pm on Oct 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Currently mysql 4.2.10. For years I've used encode() and decode() for low-level encrypting so the values could be extracted (say, as in a password retrieval.) I know the encode() data should be stored in a binary or blob field, but have always been able to insert them in a varchar field.

For whatever reason, this has stopped working in a newly created database. encode('somevalue','somepass') is truncating 'somevalue' to one or two characters. It works if I convert the field to binary or blob, but then the decode doesn't work in plain text.

Oddly enough I have other databases on the same server that are working fine. Any ideas?

rocknbil

9:30 pm on Oct 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for all your help, I think I got it. :-)

For whatever reason the software that creates database was creating it with utf8 encoding as the default. Normally I just create my own as root, but used the software provided with my server.

Usually latin1 is the default. When I converted it back to latin 1, the encode and decode functions work properly.

rocknbil

7:06 pm on Oct 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can anyone point to articles or resources as to why encode() does not work as expected in utf8? Or why utf8 is a better choice over latin1 for English? I can't seem to find anything in the documentation.