moved scrypt directory out of p2pool package
[p2pool.git] / litecoin_scrypt / scryptmodule.c
1 #include <Python.h>
2
3 //#include "scrypt.h"
4
5 static PyObject *scrypt_getpowhash(PyObject *self, PyObject *args)
6 {
7     PyStringObject *input;
8     if (!PyArg_ParseTuple(args, "S", &input))
9         return NULL;
10     Py_INCREF(input);
11     uint8_t *output = PyMem_Malloc(32);
12     scrypt_1024_1_1_256((uint8_t *)PyString_AsString((PyObject*) input), output);
13     Py_DECREF(input);
14     PyObject *value = Py_BuildValue("s#", output, 32);
15     PyMem_Free(output);
16     return value;
17 }
18
19 static PyMethodDef ScryptMethods[] = {
20     { "getPoWHash", scrypt_getpowhash, METH_VARARGS, "Returns the proof of work hash using scrypt" },
21     { NULL, NULL, 0, NULL }
22 };
23
24 PyMODINIT_FUNC initltc_scrypt(void) {
25     (void) Py_InitModule("ltc_scrypt", ScryptMethods);
26 }