Ejemplo n.º 1
0
def main(args):
    import sys
    import shutil

    if args['sha1']:
        head = read_record(sys.stdin, 0)
        sha1ucs16le = decode_head_to_sha1(head['payload'])
        sha1 = a2b_hex(sha1ucs16le.decode('utf-16le'))
        if not args['--raw']:
            sha1 = b2a_hex(sha1)
        sys.stdout.write(sha1)
    elif args['key']:
        head = read_record(sys.stdin, 0)
        key = decode_head_to_key(head['payload'])
        if not args['--raw']:
            key = b2a_hex(key)
        sys.stdout.write(key)
    else:
        result = decode(sys.stdin)
        shutil.copyfileobj(result, sys.stdout)
Ejemplo n.º 2
0
def main(args):
    import sys
    import shutil

    if args['sha1']:
        head = read_record(sys.stdin, 0)
        sha1ucs16le = decode_head_to_sha1(head['payload'])
        sha1 = a2b_hex(sha1ucs16le.decode('utf-16le'))
        if not args['--raw']:
            sha1 = b2a_hex(sha1)
        sys.stdout.write(sha1)
    elif args['key']:
        head = read_record(sys.stdin, 0)
        key = decode_head_to_key(head['payload'])
        if not args['--raw']:
            key = b2a_hex(key)
        sys.stdout.write(key)
    else:
        result = decode(sys.stdin)
        shutil.copyfileobj(result, sys.stdout)
Ejemplo n.º 3
0
 def test_distdoc_decode_head_to_key(self):
     section = self.section
     expected = self.password_sha1.upper().encode('utf-16le')[:16]
     self.assertEqual(expected, decode_head_to_key(section.head()))
     self.assertEqual(expected, section.head_key())
Ejemplo n.º 4
0
 def head_key(self):
     from hwp5.distdoc import decode_head_to_key
     payload = self.head()
     return decode_head_to_key(payload)
Ejemplo n.º 5
0
 def head_key(self):
     from hwp5.distdoc import decode_head_to_key
     payload = self.head()
     return decode_head_to_key(payload)