#!/usr/bin/env python
"""
cloak.py - Simple file encryption and/or compression utility
Copyright (C) 2010 Miroslav Stampar, Bernardo Damele A. G.
email(s): miroslav.stampar@gmail.com, bernardo.damele@gmail.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""
import os
import sys
import bz2
from optparse import OptionError
from optparse import OptionParser
def hideAscii(data):
retVal = ""
for i in xrange(len(data)):
if ord(data[i]) < 128:
retVal += chr(ord(data[i]) ^ 127)
else:
retVal += data[i]
return retVal
def cloak(inputFile):
retVal = ""
f = open(inputFile, 'rb')
original = f.read()
f.close()
data = bz2.compress(original)
return hideAscii(data)
def decloak(inputFile):
retVal = ""
f = open(inputFile, 'rb')
original = f.read()
f.close()
data = bz2.decompress(hideAscii(original))
return data
def main():
usage = '%s [-d] -i [-o