VideoHelp Forum




+ Reply to Thread
Results 1 to 6 of 6
  1. import base64
    import json


    def decode_base64(data):
    missing_padding = 4 - len(data) % 4
    if missing_padding:
    data += '=' * missing_padding
    return base64.urlsafe_b64decode(data)


    licenseServerUri = input('base64: ')
    licenseServer = decode_base64(licenseServerUri).decode('utf-8')
    licenseServerdata = json.loads(licenseServer)

    keys = ""
    for key in licenseServerdata['keys']:
    kid = key['kid']
    k = key['k']
    keys += f"--key {decode_base64(kid).hex()}:{decode_base64(k).hex() } "
    print(keys)




    Run in this form
    thank you

    main.py -b eyJrZXlzIjpbeyJrdHkiOiJvY3QiLCJhbGciOiJBMTI4S1ciLC JraWQiOiI2WURETVBLeVNTLWRoaTRRMjJscVJ3IiwiayI6IkNk U0dQZTRLUWlhcXJGdHB1anJQV2cifV19
    Quote Quote  
  2. seems it need argparse module. i never used this method, i think you can easily find argparse usage with google, not complex.

    by the way, the script works for decode clear key, right?
    Quote Quote  
  3. Code:
    import base64
    import json
    import sys
    
    def decode_base64(data):
        # Fix padding and decode base64 URL-safe string
        missing_padding = 4 - len(data) % 4
        if missing_padding:
            data += '=' * missing_padding
        return base64.urlsafe_b64decode(data)
    
    # Parse arguments (in case this code runs as a script)
    if len(sys.argv) > 2 and sys.argv[1] == '-b':
        licenseServerUri = sys.argv[2]
    else:
        licenseServerUri = input('base64: ')
    
    # Decode the base64 string
    decoded_data = decode_base64(licenseServerUri).decode('utf-8')
    licenseServerdata = json.loads(decoded_data)
    
    # Iterate over keys in the JSON and print them
    keys = ""
    for key in licenseServerdata['keys']:
        kid = key['kid']
        k = key['k']
        keys += f"--key {decode_base64(kid).hex()}:{decode_base64(k).hex()} "
    
    # Print the result
    print(keys)
    Code:
    main.py -b eyJrZXlzIjpbeyJrdHkiOiJvY3QiLCJhbGciOiJBMTI4S1ciLCJraWQiOiI2WURETVBLeVNTLWRoaTRRMjJscVJ3IiwiayI6IkNkU0dQZTRLUWlhcXJGdHB1anJQV2cifV19
    result: --key e980c330f2b2492f9d862e10db696a47:09d4863dee0a4226a aac5b69ba3acf5a
    Quote Quote  
  4. Originally Posted by sesamap159 View Post
    Code:
    import base64
    import json
    import sys
    
    def decode_base64(data):
        # Fix padding and decode base64 URL-safe string
        missing_padding = 4 - len(data) % 4
        if missing_padding:
            data += '=' * missing_padding
        return base64.urlsafe_b64decode(data)
    
    # Parse arguments (in case this code runs as a script)
    if len(sys.argv) > 2 and sys.argv[1] == '-b':
        licenseServerUri = sys.argv[2]
    else:
        licenseServerUri = input('base64: ')
    
    # Decode the base64 string
    decoded_data = decode_base64(licenseServerUri).decode('utf-8')
    licenseServerdata = json.loads(decoded_data)
    
    # Iterate over keys in the JSON and print them
    keys = ""
    for key in licenseServerdata['keys']:
        kid = key['kid']
        k = key['k']
        keys += f"--key {decode_base64(kid).hex()}:{decode_base64(k).hex()} "
    
    # Print the result
    print(keys)
    Code:
    main.py -b eyJrZXlzIjpbeyJrdHkiOiJvY3QiLCJhbGciOiJBMTI4S1ciLCJraWQiOiI2WURETVBLeVNTLWRoaTRRMjJscVJ3IiwiayI6IkNkU0dQZTRLUWlhcXJGdHB1anJQV2cifV19
    result: --key e980c330f2b2492f9d862e10db696a47:09d4863dee0a4226a aac5b69ba3acf5a
    Thank you.
    Quote Quote  
  5. Originally Posted by shellcmd View Post
    seems it need argparse module. i never used this method, i think you can easily find argparse usage with google, not complex.

    by the way, the script works for decode clear key, right?
    yes
    Quote Quote  



Similar Threads