Skip to content

Commit 2efe577

Browse files
authored
Merge pull request #46 from OnixByte/develop
Develop
2 parents 97e1448 + 971037f commit 2efe577

File tree

67 files changed

+747
-691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+747
-691
lines changed

.github/workflows/github-packages-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@ jobs:
6464
# Overwrite artefactVersion with tag name
6565
run: ./gradlew build -PartefactVersion=${{ github.event.release.tag_name }}
6666

67+
- name: List Output Items
68+
run: ls -l ./**/build/libs
69+
6770
- name: Publish to Maven Central
6871
run: ./gradlew publish

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright 2023-2024 OnixByte (HK)
190+
Copyright 2024-2025 OnixByte
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

build.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024-2024 OnixByte.
2+
* Copyright (C) 2024-2025 OnixByte.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,16 +43,12 @@ subprojects {
4343

4444
dependencies {
4545
compileOnly("org.slf4j:slf4j-api:$slf4jVersion")
46-
compileOnly("org.projectlombok:lombok:$lombokVersion")
4746
implementation("ch.qos.logback:logback-classic:$logbackVersion")
4847
annotationProcessor("org.slf4j:slf4j-api:$slf4jVersion")
49-
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
5048

5149
testCompileOnly("org.slf4j:slf4j-api:$slf4jVersion")
52-
testCompileOnly("org.projectlombok:lombok:$lombokVersion")
5350
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
5451
testAnnotationProcessor("org.slf4j:slf4j-api:$slf4jVersion")
55-
testAnnotationProcessor("org.projectlombok:lombok:$lombokVersion")
5652
}
5753

5854
tasks.withType<JavaCompile> {

devkit-core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024-2024 OnixByte.
2+
* Copyright (C) 2024-2025 OnixByte.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

devkit-core/src/main/java/com/onixbyte/devkit/core/exceptions/NotImplementedException.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024-2024 OnixByte.
2+
* Copyright (C) 2024-2025 OnixByte.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,12 +18,13 @@
1818
package com.onixbyte.devkit.core.exceptions;
1919

2020
/**
21-
* The {@code NotImplementedException} class is a custom runtime exception that represents a situation where a
22-
* particular method or functionality is not implemented or is currently unavailable in the codebase.
21+
* The {@code NotImplementedException} class is a custom runtime exception that represents a
22+
* situation where a particular method or functionality is not implemented or is currently
23+
* unavailable in the codebase.
2324
* <p>
24-
* This exception is typically thrown when developers need to indicate that a specific part of the code is incomplete
25-
* or requires further implementation. It serves as a placeholder to highlight unfinished sections of the application
26-
* during development and testing phases.
25+
* This exception is typically thrown when developers need to indicate that a specific part of the
26+
* code is incomplete or requires further implementation. It serves as a placeholder to highlight
27+
* unfinished sections of the application during development and testing phases.
2728
* <p>
2829
* Usage Example:
2930
* <pre>
@@ -33,16 +34,6 @@
3334
* This feature will be implemented in a future release.""");
3435
* }
3536
* </pre>
36-
* <b>Contact</b>
37-
* <ul>
38-
* <li>
39-
* <a href="https://github.com/CodeCraftersCN/jdevkit/issues/new"
40-
* >GitHub Issues</a>
41-
* </li>
42-
* <li>
43-
* <a href="https://discord.gg/">Discord Community</a>
44-
* </li>
45-
* </ul>
4637
*
4738
* @author Zihlu Wang
4839
* @version 1.1.0
@@ -67,7 +58,8 @@ public NotImplementedException(String message) {
6758
}
6859

6960
/**
70-
* Creates a new {@code NotImplementedException} with the specified error message and a cause for this exception.
61+
* Creates a new {@code NotImplementedException} with the specified error message and a cause
62+
* for this exception.
7163
*
7264
* @param message the error message associated with this exception
7365
* @param cause the cause of this exception
@@ -86,8 +78,8 @@ public NotImplementedException(Throwable cause) {
8678
}
8779

8880
/**
89-
* Creates a new {@code NotImplementedException} with the specified error message, cause, suppression flag, and
90-
* stack trace writable flag.
81+
* Creates a new {@code NotImplementedException} with the specified error message, cause,
82+
* suppression flag, and stack trace writable flag.
9183
*
9284
* @param message the error message associated with this
9385
* exception

devkit-core/src/main/java/com/onixbyte/devkit/core/exceptions/package-info.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

devkit-core/src/main/java/com/onixbyte/devkit/core/package-info.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

devkit-core/src/main/java/com/onixbyte/devkit/package-info.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

devkit-core/src/main/resources/logback.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
~ Copyright (C) 2023-2024 OnixByte.
3+
~ Copyright (C) 2024-2025 OnixByte.
44
~
55
~ Licensed under the Apache License, Version 2.0 (the "License");
66
~ you may not use this file except in compliance with the License.
@@ -17,8 +17,10 @@
1717
-->
1818

1919
<configuration>
20-
<property name="COLOURFUL_OUTPUT" value="%black(%date{'dd MMM, yyyy HH:mm:ss', Asia/Hong_Kong, en-UK}) %highlight(%-5level) %black(---) %black([%10.10t]) %cyan(%-20.20logger{20}) %black(:) %msg%n"/>
21-
<property name="STANDARD_OUTPUT" value="%date{'dd MMM, yyyy HH:mm:ss', Asia/Hong_Kong, en-UK} %-5level %black(---) [%10.10t] %-20.20logger{20} : %msg%n"/>
20+
<property name="COLOURFUL_OUTPUT"
21+
value="%black(%date{'dd MMM, yyyy HH:mm:ss', Asia/Hong_Kong, en-UK}) %highlight(%-5level) %black(---) %black([%10.10t]) %cyan(%-20.20logger{20}) %black(:) %msg%n"/>
22+
<property name="STANDARD_OUTPUT"
23+
value="%date{'dd MMM, yyyy HH:mm:ss', Asia/Hong_Kong, en-UK} %-5level %black(---) [%10.10t] %-20.20logger{20} : %msg%n"/>
2224

2325
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
2426
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">

devkit-core/src/test/java/com/onixbyte/devkit/core/exceptions/NotImplementationExceptionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024-2024 OnixByte.
2+
* Copyright (C) 2024-2025 OnixByte.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

devkit-utils/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024-2024 OnixByte.
2+
* Copyright (C) 2024-2025 OnixByte.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

devkit-utils/src/main/java/com/onixbyte/devkit/utils/AesUtil.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024-2024 OnixByte.
2+
* Copyright (C) 2024-2025 OnixByte.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,8 @@
1717

1818
package com.onixbyte.devkit.utils;
1919

20-
import lombok.extern.slf4j.Slf4j;
20+
import org.slf4j.Logger;
21+
import org.slf4j.LoggerFactory;
2122

2223
import javax.crypto.BadPaddingException;
2324
import javax.crypto.Cipher;
@@ -34,15 +35,44 @@
3435
import java.util.UUID;
3536

3637
/**
37-
* {@link AesUtil} can help you encrypt and decrypt data with specified secret by AES algorithm.
38+
* The {@link AesUtil} class provides utility methods for encrypting and decrypting data using the
39+
* AES algorithm. This class supports both byte array and string data, and uses a specified secret
40+
* key for encryption and decryption.
41+
* <p>
42+
* The utility methods in this class are useful for scenarios where data needs to be securely
43+
* encrypted and decrypted.
44+
* </p>
45+
*
46+
* <p><b>Example usage:</b></p>
47+
* <pre>
48+
* {@code
49+
* // Encrypting and decrypting byte array data
50+
* byte[] secretKey = "43f72073956d4c81".getBytes(StandardCharsets.UTF_8);
51+
* byte[] data = "Hello World".getBytes(StandardCharsets.UTF_8);
52+
* byte[] encryptedData = AesUtil.encrypt(data, secretKey);
53+
* byte[] decryptedData = AesUtil.decrypt(encryptedData, secretKey);
54+
* System.out.println(new String(decryptedData, StandardCharsets.UTF_8)); // Output: Hello World
55+
*
56+
* // Encrypting and decrypting string data
57+
* String secret = "43f72073956d4c81";
58+
* String encryptedString = AesUtil.encrypt("Hello World", secret);
59+
* String decryptedString = AesUtil.decrypt(encryptedString, secret);
60+
* System.out.println(decryptedString); // Output: Hello World
61+
*
62+
* // Generating a random secret key
63+
* String randomSecret = AesUtil.generateRandomSecret();
64+
* System.out.println(randomSecret); // Output: A ramdomly generated 16-character long secret
65+
* }
66+
* </pre>
3867
*
3968
* @author hubin@baomidou
4069
* @version 1.1.0
4170
* @since 1.1.0
4271
*/
43-
@Slf4j
4472
public final class AesUtil {
4573

74+
private final static Logger log = LoggerFactory.getLogger(AesUtil.class);
75+
4676
/**
4777
* Encrypts the data using the AES algorithm with the given secret.
4878
*
@@ -54,7 +84,7 @@ public static byte[] encrypt(byte[] data, byte[] secret) {
5484
try {
5585
var secretKeySpec = new SecretKeySpec(new SecretKeySpec(secret, AES).getEncoded(), AES);
5686
var cipher = Cipher.getInstance(AES_CBC_CIPHER);
57-
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(secret));
87+
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(secret)); // set IV to secret
5888
return cipher.doFinal(data);
5989
} catch (NoSuchAlgorithmException | NoSuchPaddingException | UnsupportedOperationException |
6090
InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException |
@@ -78,7 +108,7 @@ public static byte[] decrypt(byte[] data, byte[] secret) {
78108
try {
79109
var secretKeySpec = new SecretKeySpec(new SecretKeySpec(secret, AES).getEncoded(), AES);
80110
var cipher = Cipher.getInstance(AES_CBC_CIPHER);
81-
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(secret));
111+
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(secret)); // set IV to secret
82112
return cipher.doFinal(data);
83113
} catch (NoSuchAlgorithmException | NoSuchPaddingException |
84114
UnsupportedOperationException | InvalidKeyException |

devkit-utils/src/main/java/com/onixbyte/devkit/utils/Base64Util.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024-2024 OnixByte.
2+
* Copyright (C) 2024-2025 OnixByte.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,9 @@
1717

1818
package com.onixbyte.devkit.utils;
1919

20+
import org.slf4j.Logger;
21+
import org.slf4j.LoggerFactory;
22+
2023
import java.nio.charset.Charset;
2124
import java.nio.charset.StandardCharsets;
2225
import java.util.Base64;
@@ -55,6 +58,8 @@
5558
*/
5659
public final class Base64Util {
5760

61+
private final static Logger log = LoggerFactory.getLogger(Base64Util.class);
62+
5863
/**
5964
* Ensure that there is only one Base64 Encoder.
6065
*

0 commit comments

Comments
 (0)