Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1664)

Side by Side Diff: Modules/_blake2/blake2b2s.py

Issue 26798: add BLAKE2 to hashlib
Patch Set: Created 3 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Makefile.pre.in ('k') | Modules/_blake2/blake2b_impl.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python3
2
3 import os
4 import re
5
6 HERE = os.path.dirname(os.path.abspath(__file__))
7 BLAKE2 = os.path.join(HERE, 'impl')
8
9 PUBLIC_SEARCH = re.compile(r'\ int (blake2[bs]p?[a-z_]*)\(')
10
11
12 def getfiles():
13 for name in os.listdir(BLAKE2):
14 name = os.path.join(BLAKE2, name)
15 if os.path.isfile(name):
16 yield name
17
18
19 def find_public():
20 public_funcs = set()
21 for name in getfiles():
22 with open(name) as f:
23 for line in f:
24 # find public functions
25 mo = PUBLIC_SEARCH.search(line)
26 if mo:
27 public_funcs.add(mo.group(1))
28
29 for f in sorted(public_funcs):
30 print('#define {0:<18} PyBlake2_{0}'.format(f))
31
32 return public_funcs
33
34
35 def main():
36 lines = []
37 with open(os.path.join(HERE, 'blake2b_impl.c')) as f:
38 for line in f:
39 line = line.replace('blake2b', 'blake2s')
40 line = line.replace('BLAKE2b', 'BLAKE2s')
41 line = line.replace('BLAKE2B', 'BLAKE2S')
42 lines.append(line)
43 with open(os.path.join(HERE, 'blake2s_impl.c'), 'w') as f:
44 f.write(''.join(lines))
45 # find_public()
46
47
48 if __name__ == '__main__':
49 main()
OLDNEW
« no previous file with comments | « Makefile.pre.in ('k') | Modules/_blake2/blake2b_impl.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+