how should i save data like {username , passwords} to disk for later retrieval so that it cannot be opend and read in by a text editor?

I would recommend using the pickle library with the protocol set to 2. This is a binary format that should be unreadable in a text editor.

Mind you, this means that any Python program that uses your class can still un-pickle and read it. For added security, I would suggest looking into one-way cryptographic hashes (such as SHA224 or MD5) as a way of making the password unreadable: since you only need to confirm that the input password matches the stored one, you only need compare the hash of the password to the hash of the input. This makes it so that you don't need to store the password in a form that can be restored at all. This is in fact how virtually every password system in use today works, AFAIK.

already reading pckle now ///

    import cPickle as pickle
       import pickle


print 'DATA:',(data)

data_string = pickle.dumps(data)
print 'Pickle:',data_string

got it

i find shelve as an easy method of storing data in a db file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.