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

Unified Diff: Modules/_blake2/blake2b2s.py

Issue 26798: add BLAKE2 to hashlib
Patch Set: Created 3 years, 1 month ago
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Makefile.pre.in ('k') | Modules/_blake2/blake2b_impl.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
new file mode 100755
index 0000000000000000000000000000000000000000..01cf26521b37796a056eb44cf82bd2c502bb6035
--- /dev/null
+++ b/Modules/_blake2/blake2b2s.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python3
+
+import os
+import re
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+BLAKE2 = os.path.join(HERE, 'impl')
+
+PUBLIC_SEARCH = re.compile(r'\ int (blake2[bs]p?[a-z_]*)\(')
+
+
+def getfiles():
+ for name in os.listdir(BLAKE2):
+ name = os.path.join(BLAKE2, name)
+ if os.path.isfile(name):
+ yield name
+
+
+def find_public():
+ public_funcs = set()
+ for name in getfiles():
+ with open(name) as f:
+ for line in f:
+ # find public functions
+ mo = PUBLIC_SEARCH.search(line)
+ if mo:
+ public_funcs.add(mo.group(1))
+
+ for f in sorted(public_funcs):
+ print('#define {0:<18} PyBlake2_{0}'.format(f))
+
+ return public_funcs
+
+
+def main():
+ lines = []
+ with open(os.path.join(HERE, 'blake2b_impl.c')) as f:
+ for line in f:
+ line = line.replace('blake2b', 'blake2s')
+ line = line.replace('BLAKE2b', 'BLAKE2s')
+ line = line.replace('BLAKE2B', 'BLAKE2S')
+ lines.append(line)
+ with open(os.path.join(HERE, 'blake2s_impl.c'), 'w') as f:
+ f.write(''.join(lines))
+ # find_public()
+
+
+if __name__ == '__main__':
+ main()
« 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+