关于绿盾解密功能java代码。


其实也就是个文件夹复制功能,解密前提需要绿盾支持该编程工具,在编程工具中运行该代码(其中原理自己去琢磨咯)。


<span style="font-size:14px;">package com.core;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.text.DecimalFormat;

/**
 * @Classname: Decrypt
 * @Description: TODO
 * @Author: chenn_xu@sina.cn
 * @Date: 2015年10月16日 上午11:04:32
 * @Version:V1.0
 */
public class Decrypt {
	
	
	//待解密的文件夹路径
	private static String rootFolderPath = getFullpath("E:","decrypt_dev");
	//待解密文件夹路径中的文件夹
	private static String replace = "decrypt_new";
	//被替换的文件夹
	private static String beReplaced = "decrypt_dev";
	
	//解密文件数
	private static Integer fileCount = 0;
	//解密文件大小
	private static Long fileSize = new Long(0);
	
	public static void main(String[] args) {
		try {
			Long startTime = System.currentTimeMillis();
			decryptFolder(new File(rootFolderPath));
			System.out.println("------------------------------------------------------------------------------------------------");
			System.out.print("解密完成,共计耗时:"+new DecimalFormat("0.00").format((double)(System.currentTimeMillis()-startTime)/1000)+"s");
			System.out.print("\t共计文件:"+fileCount+"个");
			System.out.print("\t共计文件大小:"+new DecimalFormat(",##0.00").format((double)fileSize/1024/1024/1024)+"GB");
			System.out.print(" = "+new DecimalFormat(",##0.00").format((double)fileSize/1024/1024)+"mb");
			System.out.println(" = "+new DecimalFormat(",##0.00").format((double)fileSize/1024)+"kb");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * @Methodname: getFullpath 
	 * @Discription: TODO 拼接完整的路径  根据操作系统拼接连接符
	 * @param dir 路径
	 * @return
	 */
	private static String getFullpath(String... dir){
		StringBuffer fullPath = new StringBuffer("");
		for (int i = 0; i < dir.length; i++) {
			fullPath.append(dir[i]);
			if (dir.length-1!=i) {
				fullPath.append(File.separator);
			}
		}
		return fullPath.toString();
	}
	
	/**
	 * @Methodname: decryptFolder
	 * @Discription: TODO 解密整个文件夹
	 * @param folder 文件夹
	 * @throws Exception
	 */
	private static void decryptFolder(File folder)throws Exception {
		if (!folder.isDirectory()) {
			return;
		}
		File[] files = folder.listFiles();
		for (File file : files) {
			if (file.isFile()) {
				//进行解密操作
				decryptFile(file);
				fileCount ++;
				fileSize += file.length();
				continue ;
			}
			//创建文件夹
			File childFolder =new File(getFullpath(folder.getPath(),file.getName()));
			File newChilFolder =new File(childFolder.getPath().replaceFirst(beReplaced,replace));
			if (newChilFolder.exists()) {
				newChilFolder.delete();
			}
			newChilFolder.mkdir();
			//进行递归
			decryptFolder(childFolder);
		}
	}
	
	private static void decryptFile(File file){
		try {
	        File newFile = new File(file.getPath().replaceFirst(beReplaced,replace));
	        if (newFile.exists()) {
	        	newFile.delete();
			}
        	newFile.createNewFile();
	        FileOutputStream output = new FileOutputStream(newFile);
	        InputStream input = new FileInputStream(file);
	        int length = -1;
	        byte[] _byte = new byte[8000];
			System.out.println(file.getPath());
			int sum = input.available();
			System.out.print("文件名:"+file.getPath());
			System.out.print("\t文件大小:"+new DecimalFormat("0.00").format((double)file.length()/1024)+"kb");
			System.out.print("\t已解密大小:"+new DecimalFormat("0.00").format((double)(file.length()-input.available())/1024)+"kb");
			System.out.println("\t已解密比例:"+(sum==0?"100%":new DecimalFormat("0.00%").format((double)(sum-input.available())/sum))+"kb");
	        while ((length=input.read(_byte))!=-1) {
	        	System.out.print("文件名:"+file.getPath());
				System.out.print("\t文件大小:"+new DecimalFormat("0.00").format((double)file.length()/1024)+"kb");
				System.out.print("\t已解密大小:"+new DecimalFormat("0.00").format((double)(file.length()-input.available())/1024)+"kb");
				System.out.println("\t已解密比例:"+(sum==0?"100%":new DecimalFormat("0.00%").format((double)(sum-input.available())/sum)));
				output.write(_byte, 0, length);
			}
	        System.out.println();
	        input.close();
	        output.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }
}
</span>


你可曾遇到以下问题:员工辞职了,把公司的客户资料也拷走了;设计图纸落到了竞争对手手中;市场推广计划被个别员工泄露了……你发现在这个信息安全变得越来越重要的时代,你却对企业局域网内的信息安全束手无策。最痛苦的是,作为行政部或IT部的管理者,老板将一切责任归到你的头上……. 绿信息安全管理软件,可以帮您彻底解决以上问题。 软件名称:绿信息安全管理软件 版本信息:V1.10 大小:11.75MB 支持语言:中文版本/英文版本 适用系统:Windows 2000/XP/2003 开发商:厦门天锐科技有限公司 官方下载:www.ldsafe.com 功能简介: 一、文件加密模块 通过绿信息安全管理软件,系统在不改变用户原有工作流程和文件使用习惯的前提下,对需要保护的文件进行强制加密保护,并对文件的使用进行全程监控,即文件只能在企业局域网内部查看,离开局域网则为密文,这样有效防止了被动和主动泄密,消除内部安全隐患于无形之中。 1、系统方案:在服务器上(其他客户机可以和它通信的电脑)安装绿服务端,然后在文件服务器和需要使用共享文件的电脑上安装绿终端。在绿服务端上创建若干终端帐户,绿终端使用这些帐户登入。只有安装了绿终端的电脑在登入帐户后才可以使用或查看加密的文件,离开局域网后需要使用或查看加密文件需要得到服务端的解密或者授权才可。安装绿终端用户的文件在创建、存储、应用、传输等环节中均以加密形式存在,可以杜绝黑客工具的窃取和监听。 2、文件外发方案:如有内部文件需要外发,可把这些文件发送到只解密不加密的绿终端(通过设置登入终端的帐户类型实现),通过这些终端电脑将这些文件另存,另存后的文件即以明文的形式存在并可根据实际需要发送给企业外部客户。 3、离线方案:如企业内部员工需要带笔记本电脑脱离局域网(出差或在家查看加密文档),可以使用绿的离线策略。离线策略需要向管理员申请,获得批准后导入即可。且离线策略可以灵活设定离线使用天数,这样在方便员工外部办公的同时也有效地保证了文档的安全。 二、内网安全管理模块 1、实时操作日志 :实时详细地记录所有终端的操作日志。包括终端上窗口标题的变换、程序的启动关闭、浏览的网址、收发的邮件标题、创建删除文件等; 2、屏幕快照、屏幕追踪、屏幕回放  3、应用程序使用记录、使用限制、使用统计: 详细记录各个应用程序的开启关闭的时间,运行时间,活动时间等信息; 提供应用程序白名单和黑名单功能,方便地限制员工可以运行哪些程序,不能运行哪些程序; 4、文件及目录操作记录:详细记录文件创建、重命名、删除的情况;详细记录文件夹(目录)创建、重命名、删除等情况。 5、打印机操作记录:记录员工的打印机使用情况,包括打印的文档名、页数、打印时间等。 6、硬件使用限制: 限制使用USB设备、USB存储设备、光驱、软驱的使用。支持移动磁盘、光盘刻录文件操作的监视; 7、软硬件清单、变化记:远程列出员工计算机的软件和硬件清单及配置变化的记录; 8、YAHOO通/贸易通/新浪UC/ICQ/AOL/E话通/SKYPE/MSN专业版/TM/QQ等聊天内容记录监视 9、报警功能 10、Arp防火墙功能: 可进行IP、MAC 绑定,防止ARP攻击 。 11、远程控制功能: 重启、关闭计算机;注销WINDOWS;发送信息 。 12、资产管理功能 由于软件大于10MB,无法全部上传,只能上传一部分,请大家见谅。如果要下载的话,请到官方网站www.ldsafe.com下载。
天锐绿加密文件是一种基于RSA算法的加密方式。解密需要获得私钥,并使用私钥对加密文件进行解密。 下面是使用Python语言解密天锐绿加密文件的示例代码: ```python from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP # 读取私钥 with open('private_key.pem', 'rb') as f: private_key = RSA.import_key(f.read()) # 读取加密文件 with open('encrypted_file.txt', 'rb') as f: encrypted_data = f.read() # 使用私钥解密 cipher = PKCS1_OAEP.new(private_key) decrypted_data = cipher.decrypt(encrypted_data) # 将解密后的数据写入文件 with open('decrypted_file.txt', 'wb') as f: f.write(decrypted_data) ``` 在运行代码前,需要将私钥文件 `private_key.pem` 和加密文件 `encrypted_file.txt` 放在同一目录下,并将文件名替换成相应的文件名。 如果你不知道如何生成天锐绿加密文件的密钥和加密文件,可以参考以下步骤: 1. 安装Python的加密库 `pycryptodome`,可以使用 `pip install pycryptodome` 命令进行安装。 2. 生成RSA密钥对。可以使用以下代码生成一个2048位的RSA密钥对: ```python from Crypto.PublicKey import RSA key = RSA.generate(2048) # 将私钥写入文件 with open('private_key.pem', 'wb') as f: f.write(key.export_key()) # 将公钥写入文件 with open('public_key.pem', 'wb') as f: f.write(key.publickey().export_key()) ``` 运行代码后,将在当前目录下生成私钥文件 `private_key.pem` 和公钥文件 `public_key.pem`。 3. 加密文件。可以使用以下代码将一个字符串加密成天锐绿加密文件: ```python from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP # 读取公钥 with open('public_key.pem', 'rb') as f: public_key = RSA.import_key(f.read()) # 加密数据 cipher = PKCS1_OAEP.new(public_key) encrypted_data = cipher.encrypt(b'This is a test message.') # 将加密后的数据写入文件 with open('encrypted_file.txt', 'wb') as f: f.write(encrypted_data) ``` 运行代码后,将在当前目录下生成加密文件 `encrypted_file.txt`。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值