LUA-xxt 算法解密

本文档详细介绍了如何使用LUA-xxt解密脚本,包括涉及的main.c、xxtea.c和xxtea.h源文件,以及解密流程脚本decode.sh的使用方法。
摘要由CSDN通过智能技术生成

main.c

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"xxtea.h"
int main(int argc,char*argv[]){
	FILE*fp;
	char*key;
	char*sign;
	char*infile;
	char*outfile;
	char*buf,*data;
	unsigned long size;
	int keylen,signlen,retlen;
	if(argc<5){
		printf("usage:lua_decrypt infile outfile sign key\n");
		return -1;
	}
	else{
		infile=argv[1];
		outfile=argv[2];
		sign=argv[3];
		key=argv[4];
		keylen=strlen(key);
		signlen=strlen(sign);
	}

	if((fp=fopen(infile,"rb"))==NULL){
			perror("can't open the input file");
			return -1;
	}
	fseek(fp, 0L, SEEK_END);
	size=ftell(fp);
	rewind(fp);
	buf=(char*)malloc(size);
	fread(buf,size,1,fp);
	fclose(fp);
	data=xxtea_decrypt(buf+signlen,size-signlen,key,keylen,&retlen);
	if(data==NULL){
		printf("%s decrypt fail\n",infile);
		return -1;
	}
	if((fp=fopen(outfile,"wb+"))==NULL){
		    perror("can't open the output file");
			return -1;
	}
	fwrite(data,retlen,1,fp);
	fclose(fp);
	free(data);
	printf("%s decrypt successful\n",infile);
	return 0;

}

	

xxtea.c

/***********************************************************************
 
 Copyright 2006-2009 Ma Bingyao
 Copyright 2013 Gao Chunhui, Liu Tao
 
 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. With
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值