FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Modules/_cryptmodule.c at 3.7 · python/cpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python
/
cpython
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
35.3k
Star
74.9k
Code
Issues
5k+
Pull requests
2.6k
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Modules
/
_cryptmodule.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
71 lines (55 loc) · 1.46 KB
Breadcrumbs
cpython
/
Modules
/
_cryptmodule.c
Copy path
File metadata and controls
71 lines (55 loc) · 1.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* cryptmodule.c - by Steve Majewski
*/
#include
"Python.h"
#include
<sys/types.h>
/* Module crypt */
/*[clinic input]
module crypt
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c6252cf4f2f2ae81]*/
#include
"clinic/_cryptmodule.c.h"
/*[clinic input]
crypt.crypt
word: str
salt: str
/
Hash a *word* with the given *salt* and return the hashed password.
*word* will usually be a user's password. *salt* (either a random 2 or 16
character string, possibly prefixed with $digit$ to indicate the method)
will be used to perturb the encryption algorithm and produce distinct
results for a given *word*.
[clinic start generated code]*/
static
PyObject
*
crypt_crypt_impl
(
PyObject
*
module
,
const
char
*
word
,
const
char
*
salt
)
/*[clinic end generated code: output=0512284a03d2803c input=0e8edec9c364352b]*/
{
char
*
crypt_result
;
#ifdef
HAVE_CRYPT_R
struct
crypt_data
data
;
memset
(
&
data
,
0
,
sizeof
(
data
));
crypt_result
=
crypt_r
(
word
,
salt
,
&
data
);
#else
crypt_result
=
crypt
(
word
,
salt
);
#endif
return
Py_BuildValue
(
"s"
,
crypt_result
);
}
static
PyMethodDef
crypt_methods
[]
=
{
CRYPT_CRYPT_METHODDEF
{
NULL
,
NULL
}
/* sentinel */
};
static
struct
PyModuleDef
cryptmodule
=
{
PyModuleDef_HEAD_INIT
,
"_crypt"
,
NULL
,
-1
,
crypt_methods
,
NULL
,
NULL
,
NULL
,
NULL
};
PyMODINIT_FUNC
PyInit__crypt
(
void
)
{
return
PyModule_Create
(
&
cryptmodule
);
}
Back
|
FazBrowse Home
|
New Git URL