python - Can pickle dumps be scrambled? -
for automation project, have persist user id/password allow scripts connect remote service.
my idea use keyring module achieve better level of security; not platforms support keyring; looking storing credentials flat file, too. created "credentials" class; , figured using pickle dump/load objects of class, like:
def _store_to_file(credentials): pickle import dump pkl = open('whatever.dat', 'wb') dump(credentials, pkl) pkl.close() unfortunately, file gives away password in plain text:
s'_password' p6 s'bla' i understand file, stored local script isn't offering real security. hoping @ least point 1 need more simple "less whatever.dat" acquire password text.
i had hoped pickle has kind of "scramble" mode; couldn't find anything. overlooking something?
alternatively: there way persist objects easily, not "easy human readable"?
a simple solution; based on comment keef baker --- using aes encryption scramble on password/username; this:
class credentials(object): def __init__(self, user, password): self._user = aes.encrypt(user) self._password = aes.encrypt(password) @property def user(self): return aes.decrypt(self._user) @property def password(self): return aes.decrypt(self._password) crypto.cipher import aes aes = aes.new('this key123', aes.mode_cbc, 'this iv456')
Comments
Post a Comment