def test_distdoc_decode_head_to_sha1(self): password_sha1 = self.password_sha1 password_sha1 = password_sha1.upper() password_sha1 = password_sha1.encode('utf-16le') expected = password_sha1 section_head = self.section.head() decoded = decode_head_to_sha1(section_head) self.assertEqual(expected, decoded)
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)
def head_sha1(self): from hwp5.distdoc import decode_head_to_sha1 payload = self.head() return decode_head_to_sha1(payload)
def test_distdoc_decode_head_to_sha1(self): expected = b2a_hex(self.password_sha1).upper().encode('utf-16le') self.assertEquals(expected, decode_head_to_sha1(self.section.head()))