473,385 Members | 1,311 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,385 software developers and data experts.

Update a MYSQL db password using crypt() technology on MYSQL connection

Update a MYSQL db password using crypt() technology on MYSQL connection.

I am looking to update a user table of passwords that were inserted without using crypt() on a Perl development project. I am using MYSQL to connect to the database and I need to update the passwords to be encrypted using the same method as the website process. How do I update?

I got this far:

Expand|Select|Wrap|Line Numbers
  1.  UPDATE users SET Password = 
Dec 23 '10 #1
6 4306
AutumnsDecay
170 100+
You could do a WHILE loop for it. I don't know PERL, so this will be the PHP equivalent. I doubt they're very different for this type of thing.

Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT * FROM users";
  2. $result = mysql_result($query);
  3.  
  4. while ($row = mysql_fetch_assoc($result)){
  5.     $username = $row['username'];
  6.     $password = $row['password'];
  7.  
  8.     $newpassword = crypt($password);
  9.  
  10.     $query2 = "UPDATE users WHERE username = '$username' AND password = '$password' SET password = '$newpassword'";
  11.  
  12.     mysql_query($query2);
  13. }
  14.  
This would work in PHP, I believe, so it shouldn't be too much work to transpose it to PERL, but again, I've never used PERL.

You may or may not run into issues trying to use crypt() on an already crypted password.
Dec 23 '10 #2
Rabbit
12,516 Expert Mod 8TB
Crypt(password) doesn't work?
Dec 24 '10 #3
AutumnsDecay
170 100+
Again, I have never used PERL, I would assume crypt would work the same way as PHPs md5 function. I could be wrong.
Dec 24 '10 #4
Rabbit
12,516 Expert Mod 8TB
I don't think he's trying to use PERL to do the update. I think he's trying to do the update on the backend which means he just needs to run the SQL: update table set password = crypt(password).
Dec 24 '10 #5
I am using Windows XP, connecting using Navicat to my database (MySQL) which is hosted on cpanel. My website was written using Perl. I have inserted the usernames and passwords into the table, though the "encryption" that is being used is 'unix crypt()' When I go to update it through the Navicat interface this is the error.
[SQL] update users set password = crypt('password')

[Err] 1305 - FUNCTION databasename.crypt does not exist
Dec 28 '10 #6
Rabbit
12,516 Expert Mod 8TB
I think you have to use encrypt. I believe it's a wrapper for crypt.
Dec 28 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Torsten Schmidt | last post by:
Hi, I'm trying to connect to a mysql-Server using PHP's mysql-function mysql_connect. The host on which the mysql-server is running is not the same as the host apache and php are running on. The...
2
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling mechanism built into TomCat. I think I am having a...
0
by: John Bergstrom | last post by:
Hello everyone! I wrote a simple perl program to encrypt a string using Crypt::OpenSSL::RSA. Everything as described in the module documentation. The public key is a valid X.509 encrypted...
0
by: Ian | last post by:
Dear All, I just downloaded & installed MYSQL. It seemed to work and I can start it and enter my password and change a directory but that is about all. I have been ready and playing "hit & miss"...
0
by: aars | last post by:
Hello all, I am creating a user administration system where system administrator can activate services for a user, like webspace, a mail account or a subdomain. I now want to create a...
7
by: Nerrad | last post by:
Hi, i am currently working on a project which requires me to create a form to allow the user to change their password. I know there is a user-level security login which is easier and safer but...
9
by: christopher_board | last post by:
Hi all. I am trying to connect to a MySQL Database using PHP on a local machine using locahost. I am using the following code <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass =...
3
by: vermarajeev | last post by:
Hello friends, I am new to Perl scripts. Please help me out.... I am using crypt::CBC to encrypt my files... during decryption process it goes through the code as follows if...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.