⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cerp_crypt.java

📁 CERP系统
💻 JAVA
字号:
package com.huiton.pub.tools;

public class cerp_crypt{
   // used to encode the input string
   private static final int CRY_KEY = 15;

   // used to limit the length of the final encoded_pass
   private static final int STR_LEN = 32;

   // used to change the cry_key to every byte
   private static final int MUL_NUM = 3;

   // encode pass
   public static String get_encoded_pass(String s){
        char [] buff1 = new char[STR_LEN];
   	buff1 = s.toCharArray();
   	int b_len = buff1.length;
   	for (int i=0;i<b_len && i<STR_LEN;i++)
   		buff1[i] = (char) ((int)buff1[i]^ (CRY_KEY+MUL_NUM*i));
   	return new String(buff1);
   }

   // decode pass
   public static String get_decoded_pass(String s){
        char [] buff1 = new char[STR_LEN];
   	buff1 = s.toCharArray();
   	int b_len = buff1.length;
   	for (int i=0;i<b_len && i<STR_LEN;i++)
   		buff1[i] = (char) ((int)buff1[i]^ (CRY_KEY+MUL_NUM*i));
   	return new String(buff1);
   }

   // test program
   public static void main(String [] s){

   	for(int len=s.length, i=0; i<len; i++)
   	{
   		System.out.println("input is="+s[i]);
   		String t = get_encoded_pass(s[i]);
   		System.out.println("encoded_pass="+t);
   		System.out.println("decoded_pass="+get_decoded_pass(t));
   	}
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -