def parse_title(line):
pattern = r'tcrypt: testing speed of (.*?) (encryption|decryption)'
match = re.search(pattern, line) if match:
alg = match.group(1)
op = match.group(2) return alg, op else: return"", ""
def parse_item(line):
pattern_operations = r'\((\d+) bit key, (\d+) byte blocks\): (\d+) operations'
pattern_cycles = r'\((\d+) bit key, (\d+) byte blocks\): 1 operation in (\d+) cycles'
match = re.search(pattern_operations, line) if match:
res = { "bit_key": int(match.group(1)), "byte_blocks": int(match.group(2)), "operations": int(match.group(3)),
} return res
match = re.search(pattern_cycles, line) if match:
res = { "bit_key": int(match.group(1)), "byte_blocks": int(match.group(2)), "cycles": int(match.group(3)),
} return res
returnNone
def parse(filepath):
result = {}
alg, op = "", "" with open(filepath, 'r') as file: for line in file: ifnot line: continue
_alg, _op = parse_title(line) if _alg:
alg, op = _alg, _op if alg notin result:
result[alg] = {} if op notin result[alg]:
result[alg][op] = [] continue
parsed_result = parse_item(line) if parsed_result:
result[alg][op].append(parsed_result) return result
def merge(base, new):
merged = {} for alg in base.keys():
merged[alg] = {} for op in base[alg].keys(): if op notin merged[alg]:
merged[alg][op] = [] for index in range(len(base[alg][op])):
merged_item = { "bit_key": base[alg][op][index]["bit_key"], "byte_blocks": base[alg][op][index]["byte_blocks"],
} if"operations"in base[alg][op][index].keys():
merged_item["base_ops"] = base[alg][op][index]["operations"]
merged_item["new_ops"] = new[alg][op][index]["operations"] else:
merged_item["base_cycles"] = base[alg][op][index]["cycles"]
merged_item["new_cycles"] = new[alg][op][index]["cycles"]
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.