PersonalDataIO / CoronaRiskScoring

4 stars 2 forks source link

Extracting published TEKs #8

Open pdehaye opened 4 years ago

pdehaye commented 4 years ago

The following python function should extract TEKs from their packaged version.

import export_pb2
def process(filename):
    with open(filename, 'rb') as f:
        read_export = export_pb2.TemporaryExposureKeyExport()
        read_export.ParseFromString(f.read()[16:])    # 16 first characters are filler
        return read_export

This will require the protoc tool to be installed, and a export_pb2.proto file generated from this export.proto file by running

protoc --python_out=. export.proto

(For reference this worked like a breeze for me in figuring out the above).

pdehaye commented 4 years ago

This by @mh- is more comprehensive and helpful. Sincere thanks to him!

https://github.com/mh-/diagnosis-keys