[Tutor] Saving read-only or encoded text files?

Wayne Werner waynejwerner at gmail.com
Fri Nov 18 18:16:07 CET 2011

On Fri, Nov 18, 2011 at 11:17 AM, Max gmail <maxskywalker1 at gmail.com> wrote:

> Thank you.  This will work perfectly.
> On Nov 18, 2011, at 11:58 AM, Prasad, Ramit wrote:
> <snip>
> >
> > Any file will eventually be able to be reverse engineered, but it
> matters how much effort you care to obfuscate it. The way you can do it
> will vary based on your OS.
> >
> > For Windows, you can change the file extension to something that is not
> read by most text editors '.zxy'. It will still be able to be read if they
> try and open it with a text editor, but double clicking  will not work by
> default. You can also try setting the file attribute directly:
> http://code.activestate.com/recipes/303343-changing-file-attributes-on-windows/
> >
> > For *nix/OS X, you can prepend the file with "." as those files are
> hidden by default on most *nix systems I have used. You can also try to use
> os.chmod(0###, 'filename').
> >
> >
> > Keep in mind that all of these solutions are probably user reversible
> since the application will have the permissions of the user account it is
> run as; in most cases this is the same as the logged in user.
> <snip>

As an addition, you can also create the file using the zipfile module (
http://docs.python.org/library/zipfile.html). This adds another layer of
obfuscation and has the added benefit of making your files smaller. Of
course, the savvy user won't have any issue getting past this (Office files
are just archive files). On Ubuntu at least, if you just remove the
extension then it will attempt to discover what the filetype, and can
usually guess archive types.

It's security through obscurity, of course, so it all depends on who you're
worried about accessing this data.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111118/814d4a4b/attachment-0001.html>

More information about the Tutor mailing list