home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / palmos / pippy-0.6beta-src.tar.gz / pippy-0.6beta-src.tar / pippy-0.6beta-src / src / Modules / cryptmodule.c < prev    next >
C/C++ Source or Header  |  2000-12-21  |  949b  |  44 lines

  1. /* cryptmodule.c - by Steve Majewski
  2.  */
  3.  
  4. #include "Python.h"
  5.  
  6. #include <sys/types.h>
  7.  
  8.  
  9. /* Module crypt */
  10.  
  11.  
  12. static PyObject *crypt_crypt(self, args)
  13.     PyObject *self, *args;
  14. {
  15.     char *word, *salt; 
  16.     extern char * crypt();
  17.  
  18.     if (!PyArg_Parse(args, "(ss)", &word, &salt)) {
  19.         return NULL;
  20.     }
  21.     return PyString_FromString( crypt( word, salt ) );
  22.  
  23. }
  24.  
  25. static char crypt_crypt__doc__[] = "\
  26. crypt(word, salt) -> string\n\
  27. word will usually be a user's password. salt is a 2-character string\n\
  28. which will be used to select one of 4096 variations of DES. The characters\n\
  29. in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\
  30. the hashed password as a string, which will be composed of characters from\n\
  31. the same alphabet as the salt.";
  32.  
  33.  
  34. static PyMethodDef crypt_methods[] = {
  35.     {"crypt",    crypt_crypt, 0, crypt_crypt__doc__},
  36.     {NULL,        NULL}        /* sentinel */
  37. };
  38.  
  39. DL_EXPORT(void)
  40. initcrypt()
  41. {
  42.     Py_InitModule("crypt", crypt_methods);
  43. }
  44.