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

[*] The Base64 algorithm for the input accepts a PyByteObject object returns a...

[*] The Base64 algorithm for the input accepts a PyByteObject object returns a tuple with an encoded value and long source data. The decryption function accepts this tuple and returns a PyBytesObject object. Exceptions do not arise, but redundant data appears.
parent 51b9235d
No related branches found
No related tags found
No related merge requests found
#include "Python.h"
#include "dap_enc_base64.h"
#include "py_bytes_object_worker.h"
#ifdef __cplusplus
extern "C" {
#endif
PyObject *dap_encode_base64_py(PyObject *self, PyObject *args);
PyObject *dap_decode_base64_py(PyObject *self, PyObject *args);
\ No newline at end of file
PyObject *dap_decode_base64_py(PyObject *self, PyObject *args);
#ifdef __cplusplus
}
#endif
\ No newline at end of file
#include "wrapping_base64.h"
PyObject *dap_encode_base64_py(PyObject *self, PyObject *args){
const char* data;
if (!PyArg_ParseTuple(args, "s", &data)){
return NULL;
}
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);
PyObject *in_data;
if (!PyArg_ParseTuple(args, "S", & in_data)){
return NULL;
}
char* data = PyBytes_AsString(in_data);
size_t size_t_str = strlen(data);
char res[DAP_ENC_BASE64_ENCODE_SIZE(size_t_str)];
dap_enc_base64_encode(data, size_t_str,res, DAP_ENC_DATA_TYPE_B64);
PyBytesObject *out_obj = (PyBytesObject *)PyBytes_FromFormat("%s",res);
return Py_BuildValue("Si", out_obj, size_t_str);
}
PyObject *dap_decode_base64_py(PyObject *self, PyObject *args){
const char* data;
int size_source;
if (!PyArg_ParseTuple(args, "s|i", &data, &size_source)){
return NULL;
}
char res[size_source];
dap_enc_base64_decode(data, strlen(data), res, DAP_ENC_DATA_TYPE_B64);
return Py_BuildValue("s", res);
PyObject *data;
int size_t_str;
if (!PyArg_ParseTuple(args, "S|i", &data, &size_t_str)) {
return NULL;
}
char *in_data = PyBytes_AsString(data);
char res[size_t_str];
dap_enc_base64_decode(in_data, strlen(in_data), res, DAP_ENC_DATA_TYPE_B64);
PyObject *pyBytesObject = PyBytes_FromFormat("%s", res);
return Py_BuildValue("O", pyBytesObject);
}
\ 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