From 01e53ee9469fa4ca8aca7eb63acd99e32b3178da Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Mon, 25 Jul 2016 11:54:07 -0700 Subject: [PATCH] [pssh script] Fix invalid hex_16_bytes error on lower case input Change-Id: I274634f9076500156527c04bc9cbb9f86da3c6bd --- packager/tools/pssh/pssh-box.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packager/tools/pssh/pssh-box.py b/packager/tools/pssh/pssh-box.py index 9fb9bf4338..4e8fe12705 100755 --- a/packager/tools/pssh/pssh-box.py +++ b/packager/tools/pssh/pssh-box.py @@ -266,11 +266,15 @@ def _parse_boxes(data): def _create_argument_parser(): """Creates an argument parser.""" + def hex_16_bytes(string): if not string or len(string) != 32: raise argparse.ArgumentTypeError( 'Must be a 32-character hex string, %d given' % len(string)) - return base64.b16decode(string) + return base64.b16decode(string.upper()) + + def hex_bytes(string): + return base64.b16decode(string.upper()) parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, @@ -317,7 +321,7 @@ generate a v0 PSSH box for compatibility reasons.""") inputs.add_argument('--from-hex', metavar='', dest='input', - type=base64.b16decode, + type=hex_bytes, help='Parse the given hexadecimal encoded PSSH box') system_ids = parser.add_mutually_exclusive_group() @@ -349,7 +353,7 @@ generate a v0 PSSH box for compatibility reasons.""") help='Sets the extra data') extra.add_argument('--content-id', metavar='', - type=base64.b16decode, + type=hex_bytes, help='Sets the content ID of the Widevine PSSH data') extra.add_argument('--provider', metavar='',