469,579 Members | 1,214 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

root password in a .py script

I have to place a root password into a Python script. Is there a way to
encode it so that one can't read the password when viewing the file, but
when the sting is used it's decoded? For example:

pass = "#$%^&@*#&*$^@"
instead of:
pass = "root-password"

Thanks,

Bart
Jul 18 '05 #1
5 2096
On Fri, 12 Mar 2004 12:11:30 -0500, Bart Nessux <ba*********@hotmail.com> wrote:
I have to place a root password into a Python script. Is there a way to
encode it so that one can't read the password when viewing the file, but
when the sting is used it's decoded? For example:


The only remotely secure way is to do what Unix does in /etc/passwd (to name
a well-documented example). As far as I can see.

/Jorgen

--
// Jorgen Grahn <jgrahn@ ''If All Men Were Brothers,
\X/ algonet.se> Would You Let One Marry Your Sister?''
Jul 18 '05 #2
Bart Nessux wrote:
I have to place a root password into a Python script. Is there a way to
encode it so that one can't read the password when viewing the file, but
when the sting is used it's decoded?


No.
Jul 18 '05 #3
Bart Nessux wrote:
I have to place a root password into a Python script. Is there a way to
encode it so that one can't read the password when viewing the file, but
when the sting is used it's decoded? For example:

pass = "#$%^&@*#&*$^@"
instead of:
pass = "root-password"


Why do you need it decoded?

You could list the encrypted root
password and then if the input password
encrypts to the same thing then it means it was
a valid one.

i.
Jul 18 '05 #4
As others have pointed out, it's totally insecure, but I had to do
something similar so did...

import string

unshifted = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ'
shifted = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJ KLM'
rot13_table = string.maketrans(unshifted, shifted)

user = string.translate ('sjkeiulkje', rot13_table)
passwd = string.translate ('eorpoipoe', rot13_table)
Jul 18 '05 #5
Wayne Folta wrote:
import string

unshifted = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ'
shifted = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJ KLM'
rot13_table = string.maketrans(unshifted, shifted)

user = string.translate ('sjkeiulkje', rot13_table)
passwd = string.translate ('eorpoipoe', rot13_table)


This is actually totally equal to:

'eorpoipoe'.encode('rot13')

Gerrit.

--
Weather in Amsterdam Airport Schiphol, Netherlands 14/03 13:55 UTC:
12.0°C Few clouds mostly cloudy wind 10.3 m/s SSW (-2 m above NAP)
--
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/

Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Doug | last post: by
1 post views Thread by Adam Smith | last post: by
reply views Thread by John | last post: by
4 posts views Thread by Bob | last post: by
1 post views Thread by mattsql22 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.