annotate Modules/cryptmodule.c @ 13184:efecbbf72765 legacy-trunk

Describe a bit about writing test cases for Python...
author Skip Montanaro <skip@pobox.com>
date Fri, 30 Jun 2000 06:08:35 +0000
parents 47d70f4f635f
children 03bc51e43f7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* cryptmodule.c - by Steve Majewski
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 */
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
4 #include "Python.h"
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 #include <sys/types.h>
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 /* Module crypt */
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
12 static PyObject *crypt_crypt(self, args)
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
13 PyObject *self, *args;
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 {
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 char *word, *salt;
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 extern char * crypt();
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
18 if (!PyArg_Parse(args, "(ss)", &word, &salt)) {
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 return NULL;
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 }
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
21 return PyString_FromString( crypt( word, salt ) );
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 }
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
11687
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
25 static char crypt_crypt__doc__[] = "\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
26 crypt(word, salt) -> string\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
27 word will usually be a user's password. salt is a 2-character string\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
28 which will be used to select one of 4096 variations of DES. The characters\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
29 in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
30 the hashed password as a string, which will be composed of characters from\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
31 the same alphabet as the salt.";
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
32
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
33
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
34 static PyMethodDef crypt_methods[] = {
11687
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
35 {"crypt", crypt_crypt, 0, crypt_crypt__doc__},
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 {NULL, NULL} /* sentinel */
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 };
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
38
9588
38023a425e48 Add DL_EXPORT() to all modules that could possibly be used
Guido van Rossum <guido@python.org>
parents: 4643
diff changeset
39 DL_EXPORT(void)
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 initcrypt()
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 {
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
42 Py_InitModule("crypt", crypt_methods);
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 }