/usr/share/pyshared/ncrypt/test/encrypt.py is in python-ncrypt 0.6.4-0ubuntu8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | from ncrypt import cipher
import filterprog
otherOptsHelp = '[-c <cipher>] [-m <mode>] [--nopadding] -k <keyfile>'
def usage() :
filterprog.usage( otherOptsHelp )
def filterMain( inFile, outFile, args ) :
cipherName = args.get( '-c', 'DES-EDE3' )
modeName = args.get( '-m', 'CBC' )
fullName = '-'.join( [cipherName,modeName] )
try :
cipherType = cipher.CipherType( fullName )
except cipher.CipherError :
print 'Unknown cipher: %s' % fullName
usage()
return
keyFile = args.get( '-k', 'key.file' )
try :
key = file(keyFile,'rb').read()
except IOError :
print 'Unable to open key file: %s' % keyFile
usage()
return
try :
c = cipher.EncryptCipher( cipherType, key, None )
except cipher.CipherError, s :
print 'Error: %s' % s
usage()
return
paddingEnabled = not args.has_key('--nopadding')
c.enablePadding( paddingEnabled )
while 1 :
data = inFile.read( 1024 )
if not data : break
data = c.update( data )
outFile.write( data )
data = c.finish()
outFile.write( data )
inFile.close()
outFile.close()
if __name__ == '__main__' :
filterprog.main( filterMain, 'c:m:k:', otherOptsHelp, ['nopadding'] )
|