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

generating random passwords ... for a csv file with user details

Hi,

I have a csv file which in taken as the input file for adding users in
my linux mail server with the format

userid,fullname,passwword,dateofbith

Now I have to write a script to generate random password in the
password field for each user. A simple algorithm is sufficient for
passwords

I being new to scripting would seek all your help in doing so

Thanks In advance

kanthi

May 28 '06 #1
5 3913
import random

def rand_str(len):
chars = ''.join(['abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'1234567890',
'_+']) # plus whatever additional characters you
want
return ''.join([random.choice(chars) for i in range(len)])

print rand_str(10)

May 28 '06 #2
Kanthi skrev:
I have a csv file which in taken as the input file for adding
users in my linux mail server with the format

userid,fullname,passwword,dateofbith

Now I have to write a script to generate random password in the
password field for each user. A simple algorithm is sufficient
for passwords


#v+
import sha
sha.sha('userid,fullname,passwword,dateofbith').di gest().encode('base64')[:10] 'q0nCDQ1YdL'


#v-

Mvh,

--
Klaus Alexander Seistrup
SubZeroNet, Copenhagen, Denmark
http://magnetic-ink.dk/
May 28 '06 #3
k.i.n.g. enlightened us with:
Now I have to write a script to generate random password in the
password field for each user. A simple algorithm is sufficient for
passwords


Check out the source of pwsafe, it has a great password generator. It
can generate with different lengths, based on amount of entropy, and
can also generate different types (alpha/digit, hex, easy to read
alpha/digit, etc.)

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
May 28 '06 #4
Hi ALL,

I am sorry for not mentioning that I am new to python and scripting.
How can I add the above script to handle csv file. I want the script to
generate passwords in the passwords column/row in a csv file.

userid,realname,dateofB,passwd

The script should read the userid and genrate the password for each
user id (there are thousands of userids)

Kanthi

May 29 '06 #5
Something like:

import csv
in_csv=csv.reader( file('your INPUT filenamehere.csv') )
out_csv=csv.writer( file('your OUPUT filenamehere.csv','wb') )
## If you have a header record on your input file, then
out_csv.writerow( in_csv.next() )
## Iterate over your input file
for row in in_csv:
# Row will be a list where row[0]=userid and row[3]=passwd
password=some_function_as_advised_by_rest_of_group ()
# Assuming you want to write password as new field then
out_csv.writerow( row + [password] )
# Assuming you want to over-write password field then
row[3] = password
out_csv.writerow(row)

All the best,

Jon.

k.i.n.g. wrote:
Hi ALL,

I am sorry for not mentioning that I am new to python and scripting.
How can I add the above script to handle csv file. I want the script to
generate passwords in the passwords column/row in a csv file.

userid,realname,dateofB,passwd

The script should read the userid and genrate the password for each
user id (there are thousands of userids)

Kanthi


May 29 '06 #6

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

Similar topics

3
by: Peter Fox | last post by:
The recent thread in generating PINs reminded me: Suppose I want to give someone a random password or ID then this is what I do: (1) Generate a hash, eg. MD5 form something, possibly a random...
3
by: John Buchmann | last post by:
In my web.config, I have a section that has a name and password: <credentials passwordFormat="Clear"> <user name="aaa" password="bbb" /> </credentials> Is this secure? What is to stop...
2
by: Joe | last post by:
Hi, I am building web in ASP.NET using VB.NET to code the pages. I want to generate random passwords for users. I know that password hashing is built right into the .NET Framework. I was...
2
by: Simon Wittber | last post by:
I'm building a web application using sqlalchemy in my db layer. Some of the tables require single integer primary keys which might be exposed in some parts of the web interface. If users can...
14
by: avanti | last post by:
Hi, I need to generate random alphanumeric password strings for the users in my application using Javascript. Are there any links that will have pointers on the same? Thanks, Avanti
19
by: Cord-Heinrich Pahlmann | last post by:
Hi, I have written a tool wich de/encrypts a few of my forum and bloggin-Passwords. My question is how secure it is. The following describes how I have encrypted my passwords. When I log in,...
3
by: John | last post by:
Hi How can I generate a random password of 8 characters (digits and letters) in vb? Thanks Regards
2
by: Simon.Whiteside | last post by:
If someone has created a database for me and transferred it over is there any way that I can check I have full access to all areas? I am a beginner with Access and so the development has been...
1
by: Krimp | last post by:
I pulled this code from Vbasic.net or generating random passwords. I want to know how I can set up so that each time the page is refreshed a new password is generated without having to fill in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.