花心胡萝卜BLOG花心胡萝卜BLOG

努力,进步,创造价值. YY综合频道:84613536 集学习休闲娱乐于一身的频道!

like

AAuto AES 加密解密库

浏览(215) 评论(1) 分类:AAuto  作者:花心胡萝卜  发布时间:
分享到:

今天,写了个AAuto的AES加密解密库.

代码很简单,直接调用的Delphi写的DLL.

现在共享给大家,

如果发现什么错误,请和我说.

以下是库的代码和使用:库代码:

//Aes加密解密
/*  
 * Aes的字符串,文件的加密解密
 * 作者: Hades 
 * 版本: 0.1 
 * 日期: 2013.10.20
 * 备注: 
 *   对文件加解密的时候,需要注意传递的参数的正确性.
 *   例如:
 *     1.文件是否存在
 *     2.文件大小是否空文件
 *     3.解密的时候,传入的是否是解密的文件
 */

namespace aes{
	var dll = ..raw.loadDll("\res\AESDLL.dll");
	
	// 加密字符串
	AesEncryptString = dll.api("EncryptString","string(string srcStr, string passwd)" ,"stdcall");
	// 解密字符串
	AesDecryptString = dll.api("DecryptString","string(string srcStr, string passwd)" ,"stdcall");
	// 加密文件
	AesEncryptFile = dll.api("EncryptFile","string(stirng srcPath, string desPath, string passwd)" ,"stdcall");
	// 解密文件
	AesDecryptFile = dll.api("DecryptFile","string(stirng srcPath, string desPath, string passwd)" ,"stdcall");
}

/**intellisense()
aes.AesEncryptString(要加密的字符串, 加密密码) = @.AesEncryptString("__", "1234567890123456");
aes.AesDecryptString(要解密的字符串, 解密密码) = @.AesDecryptString("__", "1234567890123456");
aes.AesEncryptFile(要加密的文件路径, 加密文件路径, 加密密码) = @.AesEncryptFile("__", "", "1234567890123456");
aes.AesDecryptFile(要解密的文件路径, 解密文件路径, 解密密码) = @.AesDecryptFile("__", "", "1234567890123456");
end intellisense**/

调用代码:

import console;
import aes;

console.open()
console.setTitle("AAutoAes加密")

console.log("您输入的是" ,str );
var strEncry = aes.AesEncryptString("这是一个字符串!", "1234567890123456");
console.log("加密后的字符串是:", strEncry);
console.log("解密后的字符串是:", aes.AesDecryptString(strEncry, "1234567890123456"));

console.log("下面开始加密文件!");
var sEnPath = "我是文件.txt";
console.log("要加密的文件路径为:", sEnPath);
var sDePath = "我是文件_加密后.txt";
aes.AesEncryptFile(sEnPath, sDePath, "1234567890123456");
console.log("加密后的文件路径为:", sDePath);

console.log("下面开始解密文件!");
sEnPath = "我是文件_加密后.txt";
console.log("要解密的文件路径为:", sEnPath);
sDePath = "我是文件_解密后.txt";
aes.AesDecryptFile(sEnPath, sDePath, "1234567890123456");
console.log("解密后的文件路径为:", sDePath);
 
console.pause(); 
console.close();

暂时不支持设置加密位数,请等候更新.

工程源码打包:

http://www.hxcarrot.com/Download/AAutoAes加密解密.rar

Tags: AAuto AES 加密 解密  
评论
评论正在努力加载...