Java加密程序

package mypack;

import java.util.*;
/**
  @author qile_0
 * @create 2021-11-8
 * ******************
 */
public class Encry{
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("\n");
        String hint = "****************This is QILE encryption app. "+"Type 'help' for more information"+"****************\n"+"Your option:";
        while(true) {
            System.out.print(hint);
            String response = sc.next();
            System.out.println();
            if (response.equals("encry")) {
                System.out.println("***********");
                System.out.print("Enter the encryption code:");
                int encryB = 123;
                try {
                    encryB = sc.nextInt();
                    if (encryB <= 0) {
                        try {
                            throw new RuntimeException("Enter a non-negative number!");
                        } catch (RuntimeException e) {
                            System.out.println(e.getMessage());
                            break;
                        }
                    }
                } catch (InputMismatchException e) {
                    System.out.println();
                    System.out.println("Please enter a number!");
                    System.out.println();
                    break;
                }
                System.out.println();
                System.out.print("Enter the text you want to be encrypted:");
                String text = sc.next();
                char[] chars = text.toCharArray();
                for (int i = 0; i < chars.length; i++) {
                    chars[i] = (char) (chars[i] ^ encryB);
                }
                System.out.println("Your encrypted text is:");
                System.out.println(chars);
                System.out.println("***********");
            }
            else if (response.equals("code")){
                System.out.println();
                int num = new Random().nextInt(100000) + 1;
                System.out.println("your code is:" + num);
                System.out.println();
            } else if (response.equals("decry")){ System.out.println();
                System.out.print("Enter the encryption code:");
                int encryB1 = 123;
                try {
                    encryB1 = sc.nextInt();
                }catch (InputMismatchException e){
                    System.out.println();
                    System.out.println("Please enter a number!");
                    System.out.println();
                    break;
                }
                System.out.println();
                System.out.print("Enter the encrypted text:");
                String enText = sc.next();
                char[] chars1 = enText.toCharArray();
                for (int j = 0; j < chars1.length; j++) {
                    chars1[j] = (char) (chars1[j] ^ encryB1);
                }
                System.out.println("The decrypted text is:");
                System.out.println(chars1);
                System.out.println("***********");
            }else if (response.equals("help")){
                System.out.println("***********");
                System.out.println("QILE encryption app provides any encryption" +
                        " service you want.Here are some usual commands:");
                System.out.println("encry -- for encrypt a text");
                System.out.println("code -- for generating encryption code randomly");
                System.out.println("decry -- for decrypt a text");
                System.out.println("exit -- for quit the program");
                System.out.println();
                System.out.println("The encryption code(number) is a key, you will"
                        +"l need the key for decrypted and encrypted"
                        +"We suggested You should use a more longer key for safety"
                        +"Thanks very much choosing and using the QILE Encryption App!");
                System.out.println("** If you have a problem,contact us in vwu2021@outlook.com **");
                System.out.println("***********");
            }else if (response.equals("exit")) {
                System.out.println("***********");
                System.out.println("Bye,Thanks for using!");
                System.out.println("***********");
                System.exit(0);
            }
            else {
                System.out.println();
                System.out.println("Not a valid response!");
                System.out.println();
            }
        }
    }
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
简要介绍<br>JAVA CLASS文件加密工具是一款专门为保护您的JAVA源代码而设计的软件。传统的JAVA代码保护方式通常是扰乱生成的CLASS文件,从而降低反编译生成的源代码的可读性;有的保护工具甚至能生成部分废代码(垃圾代码),使得反编译后的源码在重新编译时出现编译错误,不能直接生成CLASS文件。这种方法具有一定的效果,但是不能彻底保护您的JAVA源代码。 <br><br>JAVA CLASS文件加密工具对CLASS文件进行加密保护,加密密钥高达256位(bit,即:32字节),并采用多重加密的算法,既安全又高效。加密后的CLASS文件不可能被破解;反编译工具对加密后的CLASS文件无能为力,根本就不能处理! <br><br>运行方式<br>运行时,加密后的CLASS文件要能正常加载,需要使用我们提供的动态库hidea.dll。执行java时带上参数<br>-agentlib:<动态库文件所在路径>\hidea<br>注意:不要加文件后缀.dll,直接使用文件的名字部分(classloader)!<br><br>举例说明:例如,本加密工具安装在c:\hideasoft\java_protect,执行加密后的CLASS文件的命令行如下:<br>java -agentlib:c:\hideasoft\java_protect\hidea <您的CLASS类及参数><br>应用场合<br>独立的应用程序(Application,自定义main方法),运行java时,带上参数-agentlib:<所在路径>\hidea <br>Tomcat等JAVA Web Server,修改启动脚本,把执行java的命令行加上参数-agentlib:<所在路径>\hidea <br>JBOSS等JAVA Application Server(应用服务器),修改启动脚本,把执行java的命令行加上参数-agentlib:<所在路径>\hidea <br>适用环境操作系统:Windows 98/2000/XP 等Windows系统 <br>JDK:1.5.0及以上版本

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值