|
1 |
| -from ctypes import * |
2 |
| -import sys |
3 |
| -import platform |
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +from ctypes import cdll, c_uint32, c_char_p, c_size_t, c_int, create_string_buffer |
4 | 4 | import os
|
| 5 | +import platform |
| 6 | +import sys |
5 | 7 |
|
6 | 8 |
|
7 |
| -system_type = platform.system() |
| 9 | +SYSTEM_TYPE = platform.system() |
8 | 10 | IS_PY2 = sys.version_info < (3, 0, 0, 'final', 0)
|
9 | 11 | LOCAL_LIB_PATH = "../../"
|
10 | 12 |
|
11 |
| -if system_type == "Linux": |
| 13 | +if SYSTEM_TYPE == "Linux": |
12 | 14 | LIB_NAME = "libargon2.so"
|
13 |
| -elif system_type == "Windows": |
| 15 | +elif SYSTEM_TYPE == "Windows": |
14 | 16 | LIB_NAME = "libargon2.dll"
|
15 |
| -elif system_type == "Darwin": |
| 17 | +elif SYSTEM_TYPE == "Darwin": |
16 | 18 | LIB_NAME = "libargon2.dylib"
|
17 | 19 | else:
|
18 |
| - raise OSError("Your operating systems is not fully supported, you may try to modify code manually") |
| 20 | + raise OSError("Your OS is not fully supported, you may try to modify code manually") |
19 | 21 |
|
20 | 22 | try:
|
21 | 23 | GLOBAL_LIB_PATH = os.environ['LD_LIBRARY_PATH']
|
|
28 | 30 |
|
29 | 31 | _crypto_argon2 = _argon2.argon2_hash
|
30 | 32 | _crypto_argon2.argtypes = [
|
31 |
| - c_uint32, # uint32_t N |
32 |
| - c_uint32, # uint32_t r |
33 |
| - c_uint32, # uint32_t p |
| 33 | + c_uint32, # uint32_t N |
| 34 | + c_uint32, # uint32_t r |
| 35 | + c_uint32, # uint32_t p |
34 | 36 |
|
35 |
| - c_char_p, # const uint8_t *passwd |
36 |
| - c_size_t, # size_t passwdlen |
| 37 | + c_char_p, # const uint8_t *passwd |
| 38 | + c_size_t, # size_t passwdlen |
37 | 39 |
|
38 |
| - c_char_p, # const uint8_t *salt |
39 |
| - c_size_t, # size_t saltlen |
| 40 | + c_char_p, # const uint8_t *salt |
| 41 | + c_size_t, # size_t saltlen |
40 | 42 |
|
41 |
| - c_char_p, # uint8_t *buf |
42 |
| - c_size_t, # size_t buflen |
| 43 | + c_char_p, # uint8_t *buf |
| 44 | + c_size_t, # size_t buflen |
43 | 45 |
|
44 |
| - c_char_p, # uint8_t *encoded |
45 |
| - c_size_t, # size_t encodedlen |
| 46 | + c_char_p, # uint8_t *encoded |
| 47 | + c_size_t, # size_t encodedlen |
46 | 48 |
|
47 |
| - c_uint32, # uint32_t Argon_type |
48 |
| - ] |
| 49 | + c_uint32, # uint32_t Argon_type |
| 50 | +] |
49 | 51 | _crypto_argon2.restype = c_int
|
50 | 52 |
|
51 | 53 |
|
|
0 commit comments