473,382 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

odd characters in SQL queries doing odd things to putty

LRW
I'm sorry, I don't know if this is a mySQL issue, or a Putty error, or
what. So if there's a better newsgroup for this question, please let
me know.

I'm using Putty to SSH into our remote Linux server. On one of our
mySQL databases, we have a table of users. One of the fields used to
store passwords we have as type "BLOG" and we use the ENCODE/DECODE to
encrypt passwords.

Now, when we do a select of a row from that table, because the
password field is encrypted and displays funky ASCII characters
instead of a password, I think some of those characters are being
interpreted by Putty as formatting characters because it will do some
weird things with the display.

Like this:
mysql> select * from tbl_users;
+----+----------+----------+-------------+----------+--------+----------------------------------------+-------+
| id | username | password | fullname | created | active | email
| admin |
+----+----------+----------+-------------+----------+--------+----------------------------------------+-------+
| 1 | liam | ËæËØ | LRW | 20040406 | 1 |
li**@SNIP.com | 1 |
| 2 | chipper | ÛÐ-]¿í=j | Super Duane | 20040407 | 0 |
| 0 |
| 3 | mccarter | ýàõJ¾]" | Angela | 20040412 | 1 |
cu*************@SNIP.com | 0 |
×e 4 | sarah | 0
LÒ | Sarah | 20040412 | 1 | sa***@SNIP.com | 0
|
| 5 | duane | ªéüXòTÜ | Duane | 20040412 | 1 |
de******@SNIP.com | 0 |
| 6 | Jerry1 | áÖJì | Jerry | 20040422 | 1 |
je***@SNIP.com | 0 |
| 7 | bryan | ÛÐ-]ÍJ | Bryan K | 20040512 | 1 |
| 1 |
| 8 | david | ÛÐ-éÍJ | David V | 20040512 | 1 |
| 0 |
}¼=j | Ken K | 20040512 | 1 |
| 1 |
+----+----------+----------+-------------+----------+--------+----------------------------------------+-------+
9 rows in set (0.00 sec)

I looked through Putty settings, and can't find anything that seems to
have anything to do with this issue.
So, any suggestions?

Thanks!
Liam
Jul 20 '05 #1
4 2823
LRW wrote:
I'm using Putty to SSH into our remote Linux server. On one of our
mySQL databases, we have a table of users. One of the fields used to
store passwords we have as type "BLOG"
I think you mean "BLOB".
and we use the ENCODE/DECODE to encrypt passwords.
MySQL's ENCODE function produces a sequence of binary bytes, which means
that it contains non-ASCII data. These are not necessarily viewable in
any terminal session, because they don't map to text characters. That's
the point of encrypting data, to make the original values unreadable for
those who don't know the decryption password.
Now, when we do a select of a row from that table, because the
password field is encrypted and displays funky ASCII characters
instead of a password

.. . .

If you want to see the original passwords, you must decrypt them:

SELECT DECODE(password, 'decode-password') FROM tbl_users;

where 'decode-password' is the string you used when encoding the
passwords when you entered them. If you have forgotten that decode
password, you have lost the ability to view the original password strings.

Regards,
Bill K.
Jul 20 '05 #2
On Mon, 26 Jul 2004 14:27:23 -0700, Bill Karwin wrote:
LRW wrote:
I'm using Putty to SSH into our remote Linux server...
Not relevant.
and we use the ENCODE/DECODE to encrypt passwords.


MySQL's ENCODE function produces a sequence of binary bytes, which means
that it contains non-ASCII data. These are not necessarily viewable...
Now, when we do a select of a row from that table, because the password
field is encrypted and displays funky ASCII characters...


If you want to see the original passwords, you must decrypt them:


The corollary is that if you don't want the "funky non-ASCII" then you
should not select that field as part of your selected row. I think the
only way (you cannot deselect a row) is to specify all the other fields
that you want to select. I know: PITA.

How about putting all your encrypted passwords into a separate
"encrypted_passwords" table? Use the UID as a link field between tables.
Then you would NEVER do a select from the encrypted password table,
unless you are actually decrypting it for use. Your normal select from
your user table would only show the UID (used to link to the password
table) which is printable (and not particularly secret). This is quite
common setup for database tables.

--
Juhan Leemet
Logicognosis, Inc.

Jul 20 '05 #3
Juhan Leemet wrote:
The corollary is that if you don't want the "funky non-ASCII" then you
should not select that field as part of your selected row. I think the
only way (you cannot deselect a row) is to specify all the other fields
that you want to select. I know: PITA.


You could select all columns, as well as a computed column:
select t.*, decode(t.password, 'key')
from mytable t
and then simply ignore the column that contains the encrypted binary data.

If I may make a brief tangent from the original question, I believe it
is a good practice when programming in SQL to avoid using "select *" and
also avoid using "insert into mytable values (...)" (that is, without
specifying the columns to which you are inserting). In both cases, your
SQL code might break or give unforeseen results if you add columns to
your tables.

Regards,
Bill K.
Jul 20 '05 #4
LRW
Bill Karwin <bi**@karwin.com> wrote in message news:<ce*********@enews1.newsguy.com>...
You could select all columns, as well as a computed column:
select t.*, decode(t.password, 'key')
from mytable t
and then simply ignore the column that contains the encrypted binary data.

If I may make a brief tangent from the original question, I believe it
is a good practice when programming in SQL to avoid using "select *" and
also avoid using "insert into mytable values (...)" (that is, without
specifying the columns to which you are inserting). In both cases, your
SQL code might break or give unforeseen results if you add columns to
your tables.


Thanks Bill and Juhan for your replies. I would NEVER do an INSERT
without defining the fields! But doing a SELECT * is just so easy. =)
Especially when in a querey you need to see more fields than not.
I LOVE the idea of a separate table for the passwords. I mean, that
makes perfect, obvious sense!
Thanks,
Liam
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: aurora | last post by:
I was using win32clipboard.GetClipboardData() to retrieve the Windows clipboard using code similar to the message below: ...
0
by: Hugo Fjelsted Alrøe | last post by:
I am fairly new at MySQL, so please excuse any ignorance. We are using MySQL (version 3.23.48) in connection with an Eprints = archive. We have non-english deposits in the archive, and...
8
by: LRW | last post by:
I'm sorry, I don't know if this is a mySQL issue, or a Putty error, or what. So if there's a better newsgroup for this question, please let me know. I'm using Putty to SSH into our remote Linux...
23
by: Brian | last post by:
Despite charset being discussed to death, and despite having followed all of those threads, I still have problems. http://www.tsmchughs.com/recipes/soda-bread This page uses iso-8859-1...
3
by: NeilAnderson | last post by:
I'm a fairly new user of access & I've never had any training, so I'm wondering if I'm doing the right thing here, or if it matter at all. I'm building a database for room booking purposes and I'm...
5
by: Martin Lacoste | last post by:
There's likely not a simple answer for this, I know, but, I thought I'd try anyways... Background.. I've been racking my brain with some queries that I thought were straightforward, but have...
5
by: Morten Wennevik | last post by:
I made a program than can send text to Putty (A telnet/ssh client) http://www.chiark.greenend.org.uk/~sgtatham/putty/ And I discovered that Unicode characters doesn't reach it I'm using...
27
by: Greg Smith | last post by:
Hello, I have been given a programming task that falls into the "impossible" category with my current skill set. I am hoping somebody out there knows how to do this and can save my b-t. I...
8
by: Ulysse | last post by:
Hello, I have a python script which runs all the time (using of library threading). I would like this scipt to run on a remote linux Os using Putty. The problem is, when I close Putty command...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.