Skip to content

Commit

Permalink
md5
Browse files Browse the repository at this point in the history
  • Loading branch information
martin.cong committed Oct 9, 2023
1 parent 934080d commit 900a62e
Show file tree
Hide file tree
Showing 29 changed files with 103 additions and 45 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ rpcurl.exe https://example.testapi.com/demo-java-server/Demo/hello -d '{"name":

# 各种客户端

[Dart](https://gitlab.btrpc.com/middleware/btyx-rpc-dart-client)
[Dart](https://gitlab.btrpc.com/middleware/zlkj-rpc-dart-client)

[TypeScript](https://gitlab.btrpc.com/middleware/btyx-rpc-ts-client)
[TypeScript](https://gitlab.btrpc.com/middleware/zlkj-rpc-ts-client)

[Python](https://gitlab.btrpc.com/middleware/btyx-rpc-python-client)
[Python](https://gitlab.btrpc.com/middleware/zlkj-rpc-python-client)

[go/k6](https://gitlab.btrpc.com/middleware/xk6-btrpc)

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ group=com.bt.rpc
version=1.0.0
globalRpcVersion=1.0.0
# must has high netty than grpc
quarkusTestServerVersion=3.0.2.Final
quarkusTestServerVersion=3.2.6.Final
#quarkusTestServerVersion=2.10.4.Final
#jandexVersion=0.13.2
jandexVersion=1.1.0
# 2.4.2.Final for native build
quarkusMiniSupport=3.0.2.Final
# https://quarkus.io/blog/lts-releases/
quarkusMiniSupport=3.2.6.Final
#quarkusMiniSupport=2.10.4.Final
# book libs
#https://github.com/grpc/grpc-java/blob/v1.46.x/build.gradle#L58
Expand Down
2 changes: 1 addition & 1 deletion java-rpcurl/src/main/java/com/bt/rpc/TsClientBulider.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
//public class TsClientBulider {
//
// private static String importLine = "import {RpcResult,RpcService,Headers} from '@btyx/rpc';\n\n";
// private static String importLine = "import {RpcResult,RpcService,Headers} from '@zlkj/rpc';\n\n";
// private static String importValidator = "import {\n" +
// " IsInt,\n" +
// " Length,\n" +
Expand Down
42 changes: 34 additions & 8 deletions rpc-common/src/main/java/com/bt/rpc/util/MD5.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,42 @@ private static String md5(byte[] bytes,char[] digitChars){
try {
var md5 = MessageDigest.getInstance(MD5);
var data = md5.digest(bytes);
final int l = data.length;
final char[] out = new char[l << 1];
// two characters form the hex value.
for (int i = 0, j = 0; i < l; i++) {
out[j++] = digitChars[(0xF0 & data[i]) >>> 4];
out[j++] = digitChars[0x0F & data[i]];
}
return new String(out);
//final int l = data.length;
//final char[] out = new char[l << 1];
//// two characters form the hex value.
//for (int i = 0, j = 0; i < l; i++) {
// out[j++] = digitChars[(0xF0 & data[i]) >>> 4];
// out[j++] = digitChars[0x0F & data[i]];
//}
return toStrting(data,digitChars);
} catch (final NoSuchAlgorithmException e) {
throw new IllegalArgumentException(e);
}
}

public static String toLowerStrting(byte[] digested){
return toStrting(digested,DIGITS_LOWER);
}
public static String toStrting(byte[] digested,char[] digitChars){
final int l = digested.length;
final char[] out = new char[l << 1];
//var digitChars = DIGITS_LOWER;
// two characters form the hex value.
for (int i = 0, j = 0; i < l; i++) {
out[j++] = digitChars[(0xF0 & digested[i]) >>> 4];
out[j++] = digitChars[0x0F & digested[i]];
}
return new String(out);
}

//
//public static void main(String[] args) {
// for (int i = 0; i < 32; i++) {
// //echo -n 1 | md5
// // c4ca4238a0b923820dcc509a6f75849b
// System.out.println( i +"\t" + md5(Integer.valueOf(i).toString().getBytes()));
//
// }
//}
}

2 changes: 1 addition & 1 deletion rpc-server/src/test/java/com/btyx/rpc/TestBackoffice.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* BestULearn.com Inc.
* Copyright (c) 2021-2022 All Rights Reserved.
*/
package com.btyx.rpc;
package com.zlkj.rpc;

import java.util.Arrays;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion rpc-server/src/test/java/com/btyx/rpc/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* BestULearn.com Inc.
* Copyright (c) 2021-2022 All Rights Reserved.
*/
package com.btyx.rpc;
package com.zlkj.rpc;

import java.nio.charset.StandardCharsets;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion rpc-server/src/test/java/com/btyx/rpc/TestBiz.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* BestULearn.com Inc.
* Copyright (c) 2021-2022 All Rights Reserved.
*/
package com.btyx.rpc;
package com.zlkj.rpc;

import java.util.Arrays;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion rpc-server/src/test/java/com/btyx/rpc/TestC.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* BestULearn.com Inc.
* Copyright (c) 2021-2022 All Rights Reserved.
*/
package com.btyx.rpc;
package com.zlkj.rpc;

import java.util.ArrayList;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion rpc-server/src/test/java/com/btyx/rpc/TestJwt.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Martin.Cong
* Copyright (c) 2021-2021 All Rights Reserved.
*/
package com.btyx.rpc;
package com.zlkj.rpc;

import com.bt.rpc.server.jws.JwsVerify;
import io.grpc.StatusException;
Expand Down
2 changes: 1 addition & 1 deletion rpc-server/src/test/java/com/btyx/rpc/TestPartern.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* BestULearn.com Inc.
* Copyright (c) 2021-2022 All Rights Reserved.
*/
package com.btyx.rpc;
package com.zlkj.rpc;

import java.util.Arrays;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion rpc-server/src/test/java/com/btyx/rpc/UserJwt.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* BestULearn.com Inc.
* Copyright (c) 2021-2022 All Rights Reserved.
*/
package com.btyx.rpc;
package com.zlkj.rpc;

import java.util.HashMap;
import java.util.Map;
Expand Down
2 changes: 1 addition & 1 deletion rpcurl/dart/bin/rpcurl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void main(List<String> arguments) async {

void showUsage(ArgParser parser) {
print(
'Usage: rpcurl https://demo.btyxapi.com/appName/DemoService/methodName -d \'{"param":1}\' [ or -f param.json ] ');
'Usage: rpcurl https://demo.zlkjapi.com/appName/DemoService/methodName -d \'{"param":1}\' [ or -f param.json ] ');
print('测试rpc服务\r\n');
print(parser.usage);
}
Expand Down
Binary file added rpcurl/dart/rpcurl
Binary file not shown.
4 changes: 2 additions & 2 deletions test-api/src/test/java/test/gen/TestGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class TestGen {


public static void main(String[] args) {
//Gen.basePkg = "com.btyx.test";
////Gen.basePkg = "com.btyx.course.partner.admin.service";
//Gen.basePkg = "com.zlkj.test";
////Gen.basePkg = "com.zlkj.course.partner.admin.service";
//
//var json = "{\"1-1-1\":[\"1000-01-01\",\"2081-05-08\"]}";
//
Expand Down
2 changes: 1 addition & 1 deletion test-rpc-gen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
implementation project(':rpc-api')
implementation project(':rpc-server')

// implementation 'com.btyx.common:cdn-api:1.1.1220'
// implementation 'com.zlkj.common:cdn-api:1.1.1220'
// api 'javax.validation:validation-api:2.0.1.Final'
// api 'jakarta.validation:jakarta.validation-api:2.0.2'
//
Expand Down
4 changes: 2 additions & 2 deletions test-rpc-gen/src/main/java/com/bt/rpc/gen/Gen.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class Gen {


public static String basePkg ="com.btyx";
public static String basePkg ="com.zlkj";

//static final String FC = File.separator;

Expand Down Expand Up @@ -115,7 +115,7 @@ public static void genDart(String appName, File outFolder){

static void gen(String appName, LangEnum template, File outFolder) {

//Set<ClassInfo> classesInPackage = ClassPath.from(cl).getTopLevelClassesRecursive("com.btyx");
//Set<ClassInfo> classesInPackage = ClassPath.from(cl).getTopLevelClassesRecursive("com.zlkj");
//classesInPackage.forEach(it->
//
// System.out.println(it.load()));
Expand Down
2 changes: 1 addition & 1 deletion test-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
implementation project(':rpc-server-native')
implementation project(':rpc-client')

// implementation "com.btyx.example:test-api:$globalRpcVersion"
// implementation "com.zlkj.example:test-api:$globalRpcVersion"

compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor("org.projectlombok:lombok:${lombokVersion}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//package com.btyx.test;//package com.bt;
//package com.zlkj.test;//package com.bt;
////
//import com.bt.rpc.model.RpcResult;
//import io.quarkus.runtime.annotations.RegisterForReflection;
Expand Down
2 changes: 1 addition & 1 deletion test-server/src/main/java/com/testbt/impl/InitMybatis.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// * Martin.Cong
// * Copyright (c) 2021-2021 All Rights Reserved.
// */
//package com.btyx.test.impl;
//package com.zlkj.test.impl;
//
//import java.io.IOException;
//import java.net.URISyntaxException;
Expand Down
2 changes: 1 addition & 1 deletion test-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ quarkus.hibernate-validator.fail-fast=true
quarkus.log.level=INFO
quarkus.log.console.format=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c{1.}] (%t) :%X{x-b3-traceid} %s%e%n
quarkus.log.category."org.apache.ibatis".level=DEBUG
quarkus.log.category."com.btyx.test.mapper".level=DEBUG
quarkus.log.category."com.zlkj.test.mapper".level=DEBUG
#quarkus.log.category."io.quarkus.arc".level=DEBUG

#quarkus.arc.unremovable-types=javax.validation.Validator
4 changes: 2 additions & 2 deletions test-server/src/test/java/test/btyx/ProxyServer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//package test.btyx;
//package test.zlkj;
//
//import com.btyx.test.impl.DemoServiceImpl;
//import com.zlkj.test.impl.DemoServiceImpl;
//import com.bt.rpc.common.RpcConstants;
//import com.bt.rpc.server.RpcServerBuilder;
//import io.grpc.Server;
Expand Down
2 changes: 1 addition & 1 deletion test-server/src/test/java/test/btyx/TestBookService.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.btyx;
package test.zlkj;

import com.testbt.dto.Book;
import jakarta.inject.Inject;
Expand Down
2 changes: 1 addition & 1 deletion test-server/src/test/java/test/btyx/TestRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Martin.Cong
* Copyright (c) 2021-2022 All Rights Reserved.
*/
package test.btyx;
package test.zlkj;

import com.bt.rpc.util.RefUtils;
import com.testbt.dto.Img;
Expand Down
2 changes: 1 addition & 1 deletion test-server/src/test/java/test/btyx/TestValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Martin.Cong
* Copyright (c) 2021-2023 All Rights Reserved.
*/
package test.btyx;
package test.zlkj;

import jakarta.validation.Validation;
import jakarta.validation.Validator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.btyx.jmh;
package test.zlkj.jmh;

import java.util.concurrent.TimeUnit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.btyx.jmh;
package test.zlkj.jmh;

/**
* @author gongming
Expand Down
6 changes: 3 additions & 3 deletions test-server/src/test/java/test/btyx/jmh/JmhRpcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// * Martin.Cong
// * Copyright (c) 2021-2022 All Rights Reserved.
// */
//package test.btyx.jmh;
//package test.zlkj.jmh;
//
//import java.util.concurrent.TimeUnit;
//
//import com.bt.rpc.client.RpcClientFactory;
//import com.btyx.demo.service.DemoService;
//import com.zlkj.demo.service.DemoService;
//import io.grpc.ManagedChannelBuilder;
//import org.openjdk.jmh.annotations.Benchmark;
//import org.openjdk.jmh.annotations.BenchmarkMode;
Expand Down Expand Up @@ -114,7 +114,7 @@
//
// static DemoService makeService(boolean directExecutor){
// var builder =
// ManagedChannelBuilder.forAddress("example.testbtyxapi.com",443)
// ManagedChannelBuilder.forAddress("example.testzlkjapi.com",443)
// .useTransportSecurity();
// if(directExecutor){
// builder.directExecutor();
Expand Down
35 changes: 35 additions & 0 deletions test-server/src/test/java/test/btyx/jmh/Sha256.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Zhulinkeji.com Inc.
* Copyright (c) 2021-2023 All Rights Reserved.
*/
package test.btyx.jmh;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import com.bt.rpc.util.MD5;
import com.google.common.hash.Hashing;

/**
*
* @author martin
* @version 2023/10/09 11:18
*/
public class Sha256 {
public static String jdk(byte[] b) {
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException var3) {
throw new RuntimeException("SHA-256 is not supported." + var3.getMessage());
}
byte[] d = md.digest(b);

return MD5.toLowerStrting(d);
}

public static String guava(byte[] data){
return Hashing.sha256().hashBytes(data).toString();
}

}

0 comments on commit 900a62e

Please sign in to comment.