Untitled
unknown
plain_text
2 years ago
1.3 kB
2
Indexable
Never
import json import jwt import base64 import random tokenCount = 2 randGuidCount = 1 tokens = [] communicationKeyId = "69e54088-e9e0-4530-8c1a-1eb6dcd0d14e" communicationKeyAsBase64 = "SGEpLQJ+JpeRCTMn5izu/b6kiaTH5aSXTMkEuED9fA8=" for x in range(0, tokenCount): guidNums = [] entitlementMessage = {} keyIds = [] StaticKeyId = {"id": "7459975d-b2f8-48ed-a325-56e4f34d19c7"} keyIds.append(StaticKeyId) with open("guids.json") as f: data = json.load(f) for i in range(0, randGuidCount): guidNums.append(random.randint(0, len(data))) for k in guidNums: KeyId = {"id": data[k]["id"]} keyIds.append(KeyId) entitlementMessage = { "type": "entitlement_message", "version": 2, "content_keys_source": { "inline": keyIds } } licenseServiceMessage = { "version": 1, "com_key_id": communicationKeyId, "message": entitlementMessage } print(entitlementMessage) communicationKey = base64.b64decode(communicationKeyAsBase64) jwtAsString = jwt.encode(payload=licenseServiceMessage, key=communicationKey, algorithm='HS256') tokens.append(jwtAsString) f = open('tokens.csv', 'w') for token in tokens: f.write(token+'\n') f.close()