代码拉取完成,页面将自动刷新
同步操作将从 liexusong/php-beast 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/**
* DES encrypt algorithms handler module for Beast
* @author: liexusong
*/
#include <stdlib.h>
#include <string.h>
#include "beast_log.h"
#include "beast_module.h"
#include "des_algo_lib.c"
static char key[8] = {
0x01, 0x1f, 0x01, 0x1f,
0x01, 0x0e, 0x01, 0x0e,
};
int des_encrypt_handler(char *inbuf, int len,
char **outbuf, int *outlen)
{
int blocks, i, fixcnt;
char input[8], output[8];
char *out;
int retlen;
if ((len % 8) == 0) {
fixcnt = 0;
blocks = len / 8;
} else {
fixcnt = len % 8;
blocks = len / 8 + 1;
}
retlen = blocks * 8;
out = malloc(retlen);
if (!out) {
beast_write_log(beast_log_error,
"Out of memory when allocate `%d' size by encrypt(DES)", retlen);
return -1;
}
for (i = 0; i < blocks; i++) {
memset(input, 0, 8);
/* The last block not enough 8 bytes, fix me */
if (i + 1 == blocks && fixcnt > 0) {
memcpy(input, &inbuf[i*8], fixcnt);
} else {
memcpy(input, &inbuf[i*8], 8);
}
DES_encipher(input, output, key);
memcpy(&out[i * 8], output, 8);
}
*outbuf = out;
*outlen = retlen;
return 0;
}
int des_decrypt_handler(char *inbuf, int len,
char **outbuf, int *outlen)
{
int blocks, retlen, i;
char *out;
if (len % 8 == 0) {
blocks = len / 8;
} else {
blocks = len / 8 + 1;
}
retlen = blocks * 8;
out = malloc(retlen);
if (!out) {
beast_write_log(beast_log_error,
"Out of memory when allocate `%d' size by decrypt(DES)", retlen);
return -1;
}
for (i = 0; i < blocks; i++) {
DES_decipher(&inbuf[i*8], &out[i*8], key);
}
*outbuf = out;
*outlen = retlen;
return 0;
}
void des_free_handler(void *ptr)
{
if (ptr) {
free(ptr);
}
}
struct beast_ops des_handler_ops = {
"des-algo",
des_encrypt_handler,
des_decrypt_handler,
des_free_handler,
NULL
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。