Staging
v0.5.1
https://github.com/python/cpython
Revision 3aed8d511014df6409758706e5179aeeb7cc80ee authored by Benjamin Peterson on 05 March 2009, 22:53:54 UTC, committed by Benjamin Peterson on 05 March 2009, 22:53:54 UTC
........
  r70166 | georg.brandl | 2009-03-04 12:24:41 -0600 (Wed, 04 Mar 2009) | 2 lines

  Remove obsolete stuff from string module docs.
........
  r70167 | ronald.oussoren | 2009-03-04 15:07:19 -0600 (Wed, 04 Mar 2009) | 2 lines

  Fix issue 5224.
........
  r70169 | ronald.oussoren | 2009-03-04 15:12:17 -0600 (Wed, 04 Mar 2009) | 2 lines

  Fix for issue 5226.
........
  r70176 | ronald.oussoren | 2009-03-04 15:35:05 -0600 (Wed, 04 Mar 2009) | 2 lines

  Fixes issues 3883 and 5194
........
  r70178 | ronald.oussoren | 2009-03-04 16:49:36 -0600 (Wed, 04 Mar 2009) | 2 lines

  Fix for issue #1113328.
........
  r70197 | jesus.cea | 2009-03-05 13:37:37 -0600 (Thu, 05 Mar 2009) | 1 line

  Minor bsddb documentation glitch
........
1 parent 394ee00
Raw File
Tip revision: 3aed8d511014df6409758706e5179aeeb7cc80ee authored by Benjamin Peterson on 05 March 2009, 22:53:54 UTC
Blocked revisions 70166-70167,70169,70176,70178,70197 via svnmerge
Tip revision: 3aed8d5
cryptmodule.c
/* cryptmodule.c - by Steve Majewski
 */

#include "Python.h"

#include <sys/types.h>

#ifdef __VMS
#include <openssl/des.h>
#endif

/* Module crypt */


static PyObject *crypt_crypt(PyObject *self, PyObject *args)
{
	char *word, *salt; 
#ifndef __VMS
	extern char * crypt(const char *, const char *);
#endif

	if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) {
		return NULL;
	}
	/* On some platforms (AtheOS) crypt returns NULL for an invalid
	   salt. Return None in that case. XXX Maybe raise an exception?  */
	return Py_BuildValue("s", crypt(word, salt));

}

PyDoc_STRVAR(crypt_crypt__doc__,
"crypt(word, salt) -> string\n\
word will usually be a user's password. salt is a 2-character string\n\
which will be used to select one of 4096 variations of DES. The characters\n\
in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\
the hashed password as a string, which will be composed of characters from\n\
the same alphabet as the salt.");


static PyMethodDef crypt_methods[] = {
	{"crypt",	crypt_crypt, METH_VARARGS, crypt_crypt__doc__},
	{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 to top