Skip to content
Snippets Groups Projects
Commit 30219b94 authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[*] Fixed wrapping for base58 and base64 algorithm, parsing input arguments incorrectly.

parent dcd0f031
No related branches found
No related tags found
No related merge requests found
#include "Python.h"
#include "dap_enc_base58.h"
static PyObject *dap_encode_base58_py(PyObject *self, PyObject *args);
PyObject *dap_encode_base58_py(PyObject *self, PyObject *args);
static PyObject *dap_decode_base58_py(PyObject *self, PyObject *args);
\ No newline at end of file
PyObject *dap_decode_base58_py(PyObject *self, PyObject *args);
\ No newline at end of file
#include "Python.h"
#include "dap_enc_base64.h"
static PyObject *dap_encode_base64_py(PyObject *self, PyObject *args);
PyObject *dap_encode_base64_py(PyObject *self, PyObject *args);
static PyObject *dap_decode_base64_py(PyObject *self, PyObject *args);
\ No newline at end of file
PyObject *dap_decode_base64_py(PyObject *self, PyObject *args);
\ No newline at end of file
#include "wrapping_base58.h"
static PyObject *dap_encode_base58_py(PyObject *self, PyObject *args){
PyObject *dap_encode_base58_py(PyObject *self, PyObject *args){
const char* data;
if (!PyArg_ParseTuple(self, "s", &data)){
if (!PyArg_ParseTuple(args, "s", &data)){
return NULL;
}
char* res;
size_t encode_result_size = DAP_ENC_BASE58_ENCODE_SIZE(strlen(data));
char res[encode_result_size];
dap_enc_base58_encode(data, strlen(data), res);
return Py_BuildValue("s", res);
}
static PyObject *dap_decode_base58_py(PyObject *self, PyObject *args){
PyObject *dap_decode_base58_py(PyObject *self, PyObject *args){
const char* data;
if (!PyArg_ParseTuple(self, "s", &data)){
if (!PyArg_ParseTuple(args, "s", &data)){
return NULL;
}
char* res;
size_t decode_result_size = DAP_ENC_BASE58_DECODE_SIZE(strlen(data));
char res[decode_result_size];
dap_enc_base58_decode(data, res);
return Py_BuildValue("s", res);
}
\ No newline at end of file
#include "wrapping_base64.h"
static PyObject *dap_encode_base64_py(PyObject *self, PyObject *args){
PyObject *dap_encode_base64_py(PyObject *self, PyObject *args){
const char* data;
if (!PyArg_ParseTuple(self, "s", &data)){
if (!PyArg_ParseTuple(args, "s", &data)){
return NULL;
}
char* res;
char res[DAP_ENC_BASE64_ENCODE_SIZE(strlen(data))];
dap_enc_base64_encode(data, strlen(data),res, DAP_ENC_DATA_TYPE_B64);
return Py_BuildValue("s", res);
}
static PyObject *dap_decode_base64_py(PyObject *self, PyObject *args){
PyObject *dap_decode_base64_py(PyObject *self, PyObject *args){
const char* data;
if (!PyArg_ParseTuple(self, "s", &data)){
int size_source;
if (!PyArg_ParseTuple(args, "s|i", &data, &size_source)){
return NULL;
}
char* res;
char res[size_source];
dap_enc_base64_decode(data, strlen(data), res, DAP_ENC_DATA_TYPE_B64);
return Py_BuildValue("s", res);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment