/***********************************************************************
Copyright 2006-2007 Ma Bingyao
These sources is free software. Redistributions of source code must
retain the above copyright notice. Redistributions in binary form
must reproduce the above copyright notice. You can redistribute it
freely. You can use it with any free or commercial software.
These sources is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY. Without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You may contact the author by:
e-mail: andot@coolcode.cn
*************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#if HAVE_XXTEA
#include "php_xxtea.h"
#include "ext/standard/info.h" /* for phpinfo() functions */
#include "xxtea.h"
/* compiled function list so Zend knows what's in this module */
zend_function_entry xxtea_functions[] =
{
ZEND_FE(xxtea_encrypt, NULL)
ZEND_FE(xxtea_decrypt, NULL)
ZEND_FE(xxtea_info, NULL)
{NULL, NULL, NULL}
};
/* compiled module information */
zend_module_entry xxtea_module_entry =
{
STANDARD_MODULE_HEADER,
XXTEA_MODULE_NAME,
xxtea_functions,
ZEND_MINIT(xxtea),
ZEND_MSHUTDOWN(xxtea),
NULL,
NULL,
ZEND_MINFO(xxtea),
XXTEA_VERSION,
STANDARD_MODULE_PROPERTIES
};
/* implement standard "stub" routine to introduce ourselves to Zend */
#if defined(COMPILE_DL_XXTEA)
ZEND_GET_MODULE(xxtea)
#endif
static xxtea_long *xxtea_to_long_array(unsigned char *data, xxtea_long len, int include_length, xxtea_long *ret_len) {
xxtea_long i, n, *result;
n = len >> 2;
n = (((len & 3) == 0) ? n : n + 1);
if (include_length) {
result = (xxtea_long *)emalloc((n + 1) << 2);
result[n] = len;
*ret_len = n + 1;
} else {
result = (xxtea_long *)emalloc(n << 2);
*ret_len = n;
}
memset(result, 0, n << 2);
for (i = 0; i < len; i++) {
result[i >> 2] |= (xxtea_long)data[i] << ((i & 3) << 3);
}
return result;
}
static unsigned char *xxtea_to_byte_array(xxtea_long *data, xxtea_long len, int include_length, xxtea_long *ret_len) {
xxtea_long i, n, m;
unsigned char *result;
n = len << 2;
if (include_length) {
m = data[len - 1];
if ((m < n - 7) || (m > n - 4)) return NULL;
n = m;
}
result = (unsigned char *)emalloc(n + 1);
for (i = 0; i < n; i++) {
result[i] = (unsigned char)((data[i >> 2] >> ((i & 3) << 3)) & 0xff);
}
result[n] = '\0';
*ret_len = n;
return result;
}
static unsigned char *php_xxtea_encrypt(unsigned char *data, xxtea_long len, unsigned char *key, xxtea_long *ret_len) {
unsigned char *result;
xxtea_long *v, *k, v_len, k_len;
v = xxtea_to_long_array(data, len, 1, &v_len);
k = xxtea_to_long_array(key, 16, 0, &k_len);
xxtea_long_encrypt(v, v_len, k);
result = xxtea_to_byte_array(v, v_len, 0, ret_len);
efree(v);
efree(k);
return result;
}
static unsigned char *php_xxtea_decrypt(unsigned char *data, xxtea_long len, unsigned char *key, xxtea_long *ret_len) {
unsigned char *result;
xxtea_long *v, *k, v_len, k_len;
v = xxtea_to_long_array(data, len, 0, &v_len);
k = xxtea_to_long_array(key, 16, 0, &k_len);
xxtea_long_decrypt(v, v_len, k);
result = xxtea_to_byte_array(v, v_len, 1, ret_len);
efree(v);
efree(k);
return result;
}
/* {{{ proto string xxtea_encrypt(string data, string key)
Encrypt string using XXTEA algorithm */
ZEND_FUNCTION(xxtea_encrypt)
{
unsigned char *data, *key;
unsigned char *result;
xxtea_long data_len, key_len, ret_length;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &data, &data_len, &key, &key_len) == FAILURE) {
return;
}
if (data_len == 0) RETVAL_STRINGL(NULL, 0, 0);
if (key_len != 16) RETURN_FALSE;
result = php_xxtea_encrypt(data, data_len, key, &ret_length);
if (result != NULL) {
RETVAL_STRINGL((char *)result, ret_length, 0);
} else {
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto string xxtea_decrypt(string data, string key)
Decrypt string using XXTEA algorithm */
ZEND_FUNCTION(xxtea_decrypt)
{
unsigned char *data, *key;
unsigned char *result;
xxtea_long data_len, key_len, ret_length;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &data, &data_len, &key, &key_len) == FAILURE) {
return;
}
if (data_len == 0) RETVAL_STRINGL(NULL, 0, 0);
if (key_len != 16) RETURN_FALSE;
result = php_xxtea_decrypt(data, data_len, key, &ret_length);
if (result != NULL) {
RETVAL_STRINGL((char *)result, ret_length, 0);
} else {
RETURN_FALSE;
}
}
/* }}} */
ZEND_MINIT_FUNCTION(xxtea)
{
return SUCCESS;
}
ZEND_MSHUTDOWN_FUNCTION(xxtea)
{
return SUCCESS;
}
ZEND_MINFO_FUNCTION(xxtea)
{
php_info_print_table_start();
php_info_print_table_row(2, "xxtea support", "enabled");
php_info_print_table_row(2, "xxtea module version", XXTEA_VERSION);
php_info_print_table_row(2, "xxtea author", XXTEA_AUTHOR);
php_info_print_table_row(2, "xxtea homepage", XXTEA_HOMEPAGE);
php_info_print_table_end();
}
ZEND_FUNCTION(xxtea_info)
{
array_init(return_value);
add_assoc_string(return_value, "ext_version", XXTEA_VERSION, 1);
add_assoc_string(return_value, "ext_build_date", XXTEA_BUILD_DATE, 1);
add_assoc_string(return_value, "ext_author", XXTEA_AUTHOR, 1);
add_assoc_string(return_value, "ext_homepage", XXTEA_HOMEPAGE, 1);
}
#endif /* if HAVE_XXTEA */
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
前端技术: HTML:用于定义网页结构的标记语言。 CSS :用于设计网页外观和样式的样式表语言。 JavaScript:用于在网页上实现交互性和动态效果的脚本语言。 React:一个流行的JavaScript库,用于构建用户界面。 Angular:一个用于构建Web应用的前端框架。 Vue.js:一个渐进式JavaScript框架,用于构建交互式界面。 Sass 和 Less:CSS预处理器,用于简化和加强CSS的功能。 Bootstrap:一个用于快速开发响应式网站的前端框架。 jQuery:一个流行的JavaScript库,简化了处理HTML文档、事件处理、动画等操作。 Webpack 和 Babel:前端构建工具,用于打包、转译和优化前端资源。 后端技术: Node.js:一个基于Chrome V8引擎的JavaScript运行时,用于构建高性能的后端服务。 Java:一种广泛用于后端开发的编程语言,常用于构建企业级应用。 Python:一种多用途编程语言,在Web开发中常用。 Ruby on Rails:一个基于Ruby编程语言的Web应用框架,提供了高效的开发工具。
资源推荐
资源详情
资源评论
收起资源包目录
OpenTrip是一个轻量级的旅游电商平台,基于ThinkPHP框架.zip (989个子文件)
php_xxtea.c 6KB
xxtea.c 2KB
COPYING 1KB
CREDITS 51B
bootstrap.css 144KB
bootstrap.css 144KB
buttons.css 79KB
dingzhi.css 24KB
font-awesome.min.css 22KB
main.css 19KB
umeditor.min.css 14KB
bootstrap-datetimepicker.min.css 11KB
style.css 6KB
image.css 3KB
video.css 3KB
emotion.css 2KB
mF_fancy.css 2KB
mF_fscreen_tb.css 2KB
mF_pithy_tb.css 2KB
mF_slide3D.css 2KB
mF_games_tb.css 2KB
mF_kdui.css 1KB
mF_tbhuabao.css 1KB
mF_shutters.css 1KB
mF_ladyQ.css 1KB
mF_classicHB.css 1KB
mF_classicHC.css 1KB
mF_qiyi.css 1KB
mF_kiki.css 1KB
mF_rapoo.css 1KB
mF_YSlider.css 1KB
mF_liquid.css 1KB
mF_taobao2010.css 1KB
mF_sohusports.css 1KB
mF_liuzg.css 1KB
mF_expo2010.css 1KB
mF_quwan.css 1KB
mF_peijianmall.css 1KB
mF_51xflash.css 1001B
mF_pconline.css 959B
formula.css 838B
mF_taobaomall.css 810B
mF_dleung.css 793B
mF_luluJQ.css 710B
reset.css 479B
ConfigForm.css 301B
Thumbs.db 6KB
Thumbs.db 5KB
Thumbs.db 4KB
768.dhp 40KB
512.dhp 35KB
1024.dhp 32KB
1536.dhp 28KB
3072.dhp 28KB
2048.dhp 25KB
4096.dhp 25KB
96.dhp 20KB
128.dhp 18KB
160.dhp 14KB
192.dhp 12KB
256.dhp 10KB
php_xxtea.dsp 9KB
fontawesome-webfont.eot 37KB
glyphicons-halflings-regular.eot 20KB
icons.gif 20KB
loading.gif 7KB
loading.gif 3KB
btn.gif 2KB
videologo.gif 2KB
play.gif 1KB
btn-blue.gif 1KB
ok.gif 866B
btn-bg2.gif 666B
btn-gray.gif 649B
sh-btn.gif 346B
reduce-add.gif 318B
turn.gif 316B
ar-right.gif 202B
ar-left.gif 193B
tit-ar.gif 184B
tit-ar.gif 184B
btn-bg.gif 102B
btn-red.gif 90B
ar.gif 60B
spacer.gif 43B
php_xxtea.h 1KB
xxtea.h 1KB
.htaccess 203B
customize.html 13KB
edit.html 13KB
firm.html 12KB
find.html 11KB
product.html 11KB
add.html 10KB
index.html 10KB
layout.html 7KB
formula.html 7KB
map.html 6KB
index.html 4KB
addrEdit.html 3KB
共 989 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
枫蜜柚子茶
- 粉丝: 8978
- 资源: 5351
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功