Skip to content

Commit

Permalink
Merge branch 'mycode'
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxxue committed Jun 24, 2023
2 parents 5767f2d + cd42c17 commit 34f08cf
Show file tree
Hide file tree
Showing 7 changed files with 920 additions and 562 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ sourceSets {
}

dependencies {
// 添加依赖
implementation 'cn.hutool:hutool-all:5.3.6'
implementation group: 'com.itranswarp', name: 'compiler', version: '1.0'

// 原始依赖
testImplementation "junit:junit:4.13.2"
testImplementation "org.yaml:snakeyaml:1.28"
testImplementation "javax.xml.soap:javax.xml.soap-api:1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
97 changes: 97 additions & 0 deletions src/defpackage/StrUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package defpackage;

import org.mozilla.classfile.ByteCode;
import org.mozilla.classfile.ClassFileWriter;

public class StrUtils
{

/**
* 字符串加密
*/
public static String e(String data)
{
byte[] b = data.getBytes();
for (int i = 0; i < b.length; i++)
{
b[i] = (byte) (b[i] + 1);
}
StringBuilder hex = new StringBuilder();
for (int i2 = 0; i2 < b.length; i2++)
{
hex.append(String.format("%02X", Byte.valueOf(b[i2])));
}
return hex.toString();
}

/**
* 字符串解密
*/
public static String d(String data)
{
int l = data.length() / 2;
byte[] b = new byte[l];
for (int i = 0; i < l; i++)
{
b[i] = Integer.valueOf(data.substring(i * 2, (i * 2) + 2), 16).byteValue();
}
for (int i2 = 0; i2 < b.length; i2++)
{
b[i2] = (byte) (b[i2] - 1);
}
return new String(b);
}

/**
* 加密,把一个字符串在原有的基础上 加一个数值
*/
public static String e2(String data)
{

//把字符串转为字节数组
byte[] b = data.getBytes();
//遍历
for (int i = 0; i < b.length; i++)
{
b[i] += 3;//在原有的基础上 加一个数值
}
return new String(b);
}

/**
* 解密:把一个加密后的字符串在原有基础上 减一个数
*
* @param data 加密后的字符串
* @return 返回解密后的新字符串
*/
public static String d2(String data)
{
//把字符串转为字节数组
byte[] b = data.getBytes();
//遍历
for (int i = 0; i < b.length; i++)
{
b[i] -= 3;//在原有的基础上 减一个数
}
return new String(b);
}

/**
* 字符串加密
*/
public static void strE(ClassFileWriter cfw, String content)
{
//System.out.println(content);
if (content.isEmpty())
{
//为空 则 不调用 解密..
cfw.addPush(content);
}
else
{
cfw.addPush(StrUtils.e(content));
cfw.addInvoke(ByteCode.INVOKESTATIC, "defpackage.StrUtils", "d", "(Ljava/lang/String;)" +
"Ljava/lang/String;");
}
}
}
6 changes: 6 additions & 0 deletions src/org/mozilla/classfile/ClassFileWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,12 @@ public void addPush(double k) {
* @param k the constant
*/
public void addPush(String k) {

if (k == null)
{
k = "";
}

int length = k.length();
int limit = itsConstantPool.getUtfEncodingLimit(k, 0, length);
if (limit == length) {
Expand Down
Loading

0 comments on commit 34f08cf

Please sign in to comment.