Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (1)

Powered by Vanilla. Made with Bootstrap.
xor encoder v2.0
  • s1n4
    Posts: 88
    Another version of xor encoder

    #!/usr/bin/python

    ################################
    ##### #####
    ##### Xor encoder #####
    ##### For encoding file #####
    ##### #####
    ##### Writen by s1n4 #####
    ##### June 16 , 2011 #####
    ##### 3:55 AM #####
    ##### #####
    ################################

    import sys

    def usage() :
    print 'Usage: %s [Key] [File]' % sys.argv[0]
    exit()

    def xor(key, fn) :
    try :
    Input = open(fn, 'rb').read()

    except IOError :
    usage()

    res = ''
    c = 0

    for i in Input :
    res += chr(ord(i) ^ ord(key[c]))
    if c == len(key) - 1 :
    c = 0
    continue

    c += 1

    try :
    Output = open(fn, 'wb')
    Output.write(res)

    finally :
    Output.close()
    print key, 'xor', fn

    def main() :
    if len(sys.argv) == 3 :
    xor(sys.argv[1], sys.argv[2])

    else :
    usage()

    main()


    For example :
    xor.py s1n4 test.zip


    For access to the original file you must xor again with latest key.