{"id":26891053,"url":"https://github.com/tagaryen/archer-tools","last_synced_at":"2025-06-19T01:33:45.493Z","repository":{"id":266413229,"uuid":"898255026","full_name":"tagaryen/archer-tools","owner":"tagaryen","description":"Useful tools written with java. Includes ecdsa, sm2, sm3, encryption, excel reader, http(s) client and server etc.","archived":false,"fork":false,"pushed_at":"2025-04-10T06:16:21.000Z","size":156,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T13:03:42.294Z","etag":null,"topics":["asm","bytecode","elliptic-curves","excel","http","http-client","http-server","https","rsa","secp256k1","sm2","sm3","sm4","toolbox"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tagaryen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-04T04:17:03.000Z","updated_at":"2025-04-10T06:16:24.000Z","dependencies_parsed_at":"2024-12-04T06:29:09.525Z","dependency_job_id":"53d481ce-ff35-4fb4-8381-4fd2da431f88","html_url":"https://github.com/tagaryen/archer-tools","commit_stats":null,"previous_names":["tagaryen/archer-tools"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tagaryen/archer-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tagaryen%2Farcher-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tagaryen%2Farcher-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tagaryen%2Farcher-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tagaryen%2Farcher-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tagaryen","download_url":"https://codeload.github.com/tagaryen/archer-tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tagaryen%2Farcher-tools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260662944,"owners_count":23044029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asm","bytecode","elliptic-curves","excel","http","http-client","http-server","https","rsa","secp256k1","sm2","sm3","sm4","toolbox"],"created_at":"2025-03-31T22:12:46.753Z","updated_at":"2025-06-19T01:33:40.480Z","avatar_url":"https://github.com/tagaryen.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# archer-tools\nUseful tools written with pure java. Includes ecdsa, sm2, sm3, encryption, excel reader, http(s) client and server etc.  \nmaven:\n``` maven\n        \u003cdependency\u003e\n\t  \u003cgroupId\u003eio.github.tagaryen\u003c/groupId\u003e  \n\t  \u003cartifactId\u003earcher-tools\u003c/artifactId\u003e  \n\t  \u003cversion\u003e1.2.19\u003c/version\u003e  \n\t\u003c/dependency\u003e  \n```\n\n## Asm java bytecode\nsee [AsyncProxy.java](https://github.com/Archerxy/archer-framework/blob/main/src/main/java/com/archer/framework/base/async/AsyncProxy.java) and [TestService.test1](https://github.com/Archerxy/archer-framework/blob/main/src/demos/com/archer/test/run/TestService.java) call Async test3()   \nthe example shows how to use 'com.archer.tools.bytecode.ClassBytecode' for generating a child class and change the behavier of the super class  \n\n## Digital signatures  \n``` java  \n    byte[] sk = {29, -3, 74, 47, 123, 64, 41, 123, 67, -9, 89, 16, 84, 115, 18, -8, -41, -97, -57, 36, 103, 60, 115, -123, -5, -38, -97, 127, 32, -21, -25, 2};  \n    byte[] pk = {36, 117, -87, 86, -21, 0, 78, 37, -128, -38, -1, -36, -74, -16, 60, -55, -46, 47, -29, -101, 95, 53, 113, 31, 0, 37, -46, 89, -70, -126, 10, -86, 44, -69, -127, -11, -19, 120, -83, 90, 46, 81, 15, -101, -16, -87, -106, -67, -33, -23, 18, 54, -67, 36, 99, 11, 59, -73, -96, 99, -98, 95, -115, -68};  \n    byte[] hash = {21, -31, 75, 47, 123, 64, 41, 123, 67, -9, 89, 16, 84, 115, 18, -8, -41, -97, -57, 36, 103, 60, 115, -123, -5, -38, -97, 127, 32, -21, -25, 2};  \n    Signature sig = new Signature(Signature.PopularCurve.secp256k1);  \n  \n    byte[] rs = sig.sign(sk, hash);  \n    // print result  \n    System.out.println(\"ret: \"+sig.verify(pk, hash, rs));  \n    \n    byte[] sm2Sk = {29, -3, 74, 47, 123, 64, 41, 123, 67, -9, 89, 16, 84, 115, 18, -8, -41, -97, -57, 36, 103, 60, 115, -123, -5, -38, -97, 127, 32, -21, -25, 2};\n    byte[] sm2Pk = {124, -111, 78, 61, -127, 10, -126, -115, 18, -118, 16, 64, 63, -12, 77, 32, 8, 95, -32, 73, 36, 98, 63, -81, -1, -112, -45, -87, -119, -31, -91, -5, -76, 120, -20, -101, -57, 45, -115, -110, -52, -50, 83, -74, -117, -113, -38, -51, -125, 18, -42, -84, 59, -33, -105, -3, 23, -8, 83, 51, 45, 74, -31, -105};\n    Signature sig = new Signature(Signature.PopularCurve.sm2p256v1);\n\n    rs = sig.sign(sm2Sk, hash);\n    // print result\n    System.out.println(\"ret: \"+sig.verify(sm2Pk, hash, rs));\n```   \n\n## crypto\n``` java  \n    SM2KeyPair keypair = SM2Crypto.genSM2KeyPair();\n    byte[] pri = keypair.getPrivateKey();\n    byte[] pub = keypair.getPublicKey(); //SM2Crypto.getPublicKeyFromPrivateKey(pri);\n    \t\n    \t\n    byte[] data = \"nihao, shuaige\".getBytes();\n    byte[] cipher = SM2Crypto.encrypt(pub, data, SM2CryptoMode.C1C2C3);\n    // print cipher\n    System.out.println(Arrays.toString(cipher));\n    byte[] text = SM2Crypto.decrypt(pri, cipher, SM2CryptoMode.C1C2C3);\n    // print text\n    System.out.println(new String(text));\n```  \n\n## http(s) client\n``` java   \n    String body = JSONRequest.get(\"https://www.baidu.com\");\n    // print body\n    System.out.println(body);\n\n    BaseRequest\u003cUserLoginReqVO\u003e userLoginReq = ...;\n    BaseResonse\u003cUserLoginRspVO\u003e userLoginRsp = JSONRequest.post(\"http://localhost:8080/api/test/login\", userLoginReq, new JavaTypeRef\u003cBaseResonse\u003cUserLoginRspVO\u003e\u003e() {});\n    // print body\n    System.out.println(userLoginRsp);\n```  \n\n## http(s) server\n``` java  \n    (new SimpleHttpServer()).listen(8080, new HttpListener() {\n        @Override\n        public void inComingMessage(HttpRequest req, HttpResponse res) {\n            // print request body\n            System.out.println(\"req: \" + new String(req.getContent()));\n            String body = \"{\\\"nihao\\\":\\\"shuaige\\\"}\";\n            res.setContentType(ContentType.APPLICATION_JSON);\n            res.setContent(body.getBytes());\n            }\n\n        @Override\n        public void onServerException(HttpRequest req, HttpResponse res, Throwable t) {\n            t.printStackTrace();\n        }\n    });\n```  \n\n## read a xlsx file\n``` java  \n    // reading a middle size file\n    List\u003cSheet\u003e sheets = XlsxReader.read(\"e:/work/10w_line.xlsx\");\n    for(Sheet s: sheets) {\n        System.out.println(s.getName());\n        for(Row r: s.rows()) {\n            for(Cell c: r.cells()) {\n                System.out.println(c.getName() + \":\" + c.getValue());\n            }\n        }\n    }\n\n    // reading a large size file\n    List\u003cSimpleSheet\u003e simpleSheets = SimpleXlsxReader.read(\"e:/work/100w_line.xlsx\");\n    for(SimpleSheet s: simpleSheets) {\n        System.out.println(s.getName());\n        for(List\u003cString\u003e row: s.rows()) {\n            for(String cell: row) {\n                System.out.println(cell);\n            }\n        }\n    }\n```  \n\n## RPC \n``` java  \n    ARPCServer server = new ARPCServer(\"127.0.0.1\", 9612);\n    ARPCClient client = new ARPCClient(\"127.0.0.1\", 9612);\n\n    server.registerListener(new ARPCServerListenner\u003cMessageB, MessageC\u003e(MessageB.class, MessageC.class) {\n        @Override\n        public MessageC onMessage(MessageB p) {\n            System.out.println(\"receive client messageB \" + XJSONStatic.stringify(p));\n            return new MessageC();\n    }});\n    server.registerListener(new ARPCServerListenner\u003cMessageA, MessageB\u003e(MessageA.class, MessageB.class) {\n        @Override\n        public MessageB onMessage(MessageA p) {\n            System.out.println(\"receive client messageA \" + XJSONStatic.stringify(p));\n            return new MessageB();\n    }});\n\n    server.start();\n\n    client.registerListener(new ARPCClientListenner\u003cMessageB, MessageC\u003e(MessageB.class, MessageC.class));\n    client.registerListener(new ARPCClientListenner\u003cMessageA, MessageB\u003e(MessageA.class, MessageB.class));\n\n    client.callRemoteAsync(new MessageB(), new ARPCClientCallback\u003cMessageC\u003e() {\n        @Override\n        public void onReturn(MessageC r) {\n            System.out.println(\"client receive MessageC \" + XJSONStatic.stringify(r));\n        }});\n    MessageB b = client.callRemote(new MessageA(), MessageB.class);\n    System.out.println(\"client receive MessageB \" + XJSONStatic.stringify(b));\n\n    try {\n        Thread.sleep(3000);\n    } catch (InterruptedException e) {\n        e.printStackTrace();\n    }\n\n    client.close();\n    server.close();\n```  \n\n## sort algorithm\n``` java  \n    int count = 100000000;\n    Integer[] a = new Integer[count];\n    Random r = new Random();\n    for(int i = 0; i \u003c count; i++) {\n        a[i] = r.nextInt(count);\n    }\n\t\n    System.out.println(Arrays.toString(Arrays.copyOfRange(a, 0, 20)));\n    System.out.println(Arrays.toString(Arrays.copyOfRange(a, count -20, count)));\n    QuickSort.sort(a, new Comparison\u003cInteger\u003e() {\n        @Override\n        public int compare(Integer o1, Integer o2) {\n            return o1 - o2;\n    }});\n\n    System.out.println(Arrays.toString(Arrays.copyOfRange(a, 0, 20)));\n    System.out.println(Arrays.toString(Arrays.copyOfRange(a, count -20, count)));\n```  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftagaryen%2Farcher-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftagaryen%2Farcher-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftagaryen%2Farcher-tools/lists"}