Skip to content

Commit

Permalink
Merge pull request #46 from OnixByte/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
zihluwang authored Jan 25, 2025
2 parents 97e1448 + 971037f commit 2efe577
Show file tree
Hide file tree
Showing 67 changed files with 747 additions and 691 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/github-packages-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ jobs:
# Overwrite artefactVersion with tag name
run: ./gradlew build -PartefactVersion=${{ github.event.release.tag_name }}

- name: List Output Items
run: ls -l ./**/build/libs

- name: Publish to Maven Central
run: ./gradlew publish
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2023-2024 OnixByte (HK)
Copyright 2024-2025 OnixByte

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 1 addition & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024-2024 OnixByte.
* Copyright (C) 2024-2025 OnixByte.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,16 +43,12 @@ subprojects {

dependencies {
compileOnly("org.slf4j:slf4j-api:$slf4jVersion")
compileOnly("org.projectlombok:lombok:$lombokVersion")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
annotationProcessor("org.slf4j:slf4j-api:$slf4jVersion")
annotationProcessor("org.projectlombok:lombok:$lombokVersion")

testCompileOnly("org.slf4j:slf4j-api:$slf4jVersion")
testCompileOnly("org.projectlombok:lombok:$lombokVersion")
testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion")
testAnnotationProcessor("org.slf4j:slf4j-api:$slf4jVersion")
testAnnotationProcessor("org.projectlombok:lombok:$lombokVersion")
}

tasks.withType<JavaCompile> {
Expand Down
2 changes: 1 addition & 1 deletion devkit-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024-2024 OnixByte.
* Copyright (C) 2024-2025 OnixByte.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024-2024 OnixByte.
* Copyright (C) 2024-2025 OnixByte.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,12 +18,13 @@
package com.onixbyte.devkit.core.exceptions;

/**
* The {@code NotImplementedException} class is a custom runtime exception that represents a situation where a
* particular method or functionality is not implemented or is currently unavailable in the codebase.
* The {@code NotImplementedException} class is a custom runtime exception that represents a
* situation where a particular method or functionality is not implemented or is currently
* unavailable in the codebase.
* <p>
* This exception is typically thrown when developers need to indicate that a specific part of the code is incomplete
* or requires further implementation. It serves as a placeholder to highlight unfinished sections of the application
* during development and testing phases.
* This exception is typically thrown when developers need to indicate that a specific part of the
* code is incomplete or requires further implementation. It serves as a placeholder to highlight
* unfinished sections of the application during development and testing phases.
* <p>
* Usage Example:
* <pre>
Expand All @@ -33,16 +34,6 @@
* This feature will be implemented in a future release.""");
* }
* </pre>
* <b>Contact</b>
* <ul>
* <li>
* <a href="https://github.com/CodeCraftersCN/jdevkit/issues/new"
* >GitHub Issues</a>
* </li>
* <li>
* <a href="https://discord.gg/">Discord Community</a>
* </li>
* </ul>
*
* @author Zihlu Wang
* @version 1.1.0
Expand All @@ -67,7 +58,8 @@ public NotImplementedException(String message) {
}

/**
* Creates a new {@code NotImplementedException} with the specified error message and a cause for this exception.
* Creates a new {@code NotImplementedException} with the specified error message and a cause
* for this exception.
*
* @param message the error message associated with this exception
* @param cause the cause of this exception
Expand All @@ -86,8 +78,8 @@ public NotImplementedException(Throwable cause) {
}

/**
* Creates a new {@code NotImplementedException} with the specified error message, cause, suppression flag, and
* stack trace writable flag.
* Creates a new {@code NotImplementedException} with the specified error message, cause,
* suppression flag, and stack trace writable flag.
*
* @param message the error message associated with this
* exception
Expand Down

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions devkit-core/src/main/java/com/onixbyte/devkit/package-info.java

This file was deleted.

8 changes: 5 additions & 3 deletions devkit-core/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2023-2024 OnixByte.
~ Copyright (C) 2024-2025 OnixByte.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -17,8 +17,10 @@
-->

<configuration>
<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"/>
<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"/>
<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"/>
<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"/>

<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024-2024 OnixByte.
* Copyright (C) 2024-2025 OnixByte.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion devkit-utils/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024-2024 OnixByte.
* Copyright (C) 2024-2025 OnixByte.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
42 changes: 36 additions & 6 deletions devkit-utils/src/main/java/com/onixbyte/devkit/utils/AesUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024-2024 OnixByte.
* Copyright (C) 2024-2025 OnixByte.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,8 @@

package com.onixbyte.devkit.utils;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
Expand All @@ -34,15 +35,44 @@
import java.util.UUID;

/**
* {@link AesUtil} can help you encrypt and decrypt data with specified secret by AES algorithm.
* The {@link AesUtil} class provides utility methods for encrypting and decrypting data using the
* AES algorithm. This class supports both byte array and string data, and uses a specified secret
* key for encryption and decryption.
* <p>
* The utility methods in this class are useful for scenarios where data needs to be securely
* encrypted and decrypted.
* </p>
*
* <p><b>Example usage:</b></p>
* <pre>
* {@code
* // Encrypting and decrypting byte array data
* byte[] secretKey = "43f72073956d4c81".getBytes(StandardCharsets.UTF_8);
* byte[] data = "Hello World".getBytes(StandardCharsets.UTF_8);
* byte[] encryptedData = AesUtil.encrypt(data, secretKey);
* byte[] decryptedData = AesUtil.decrypt(encryptedData, secretKey);
* System.out.println(new String(decryptedData, StandardCharsets.UTF_8)); // Output: Hello World
*
* // Encrypting and decrypting string data
* String secret = "43f72073956d4c81";
* String encryptedString = AesUtil.encrypt("Hello World", secret);
* String decryptedString = AesUtil.decrypt(encryptedString, secret);
* System.out.println(decryptedString); // Output: Hello World
*
* // Generating a random secret key
* String randomSecret = AesUtil.generateRandomSecret();
* System.out.println(randomSecret); // Output: A ramdomly generated 16-character long secret
* }
* </pre>
*
* @author hubin@baomidou
* @version 1.1.0
* @since 1.1.0
*/
@Slf4j
public final class AesUtil {

private final static Logger log = LoggerFactory.getLogger(AesUtil.class);

/**
* Encrypts the data using the AES algorithm with the given secret.
*
Expand All @@ -54,7 +84,7 @@ public static byte[] encrypt(byte[] data, byte[] secret) {
try {
var secretKeySpec = new SecretKeySpec(new SecretKeySpec(secret, AES).getEncoded(), AES);
var cipher = Cipher.getInstance(AES_CBC_CIPHER);
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(secret));
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(secret)); // set IV to secret
return cipher.doFinal(data);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | UnsupportedOperationException |
InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException |
Expand All @@ -78,7 +108,7 @@ public static byte[] decrypt(byte[] data, byte[] secret) {
try {
var secretKeySpec = new SecretKeySpec(new SecretKeySpec(secret, AES).getEncoded(), AES);
var cipher = Cipher.getInstance(AES_CBC_CIPHER);
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(secret));
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(secret)); // set IV to secret
return cipher.doFinal(data);
} catch (NoSuchAlgorithmException | NoSuchPaddingException |
UnsupportedOperationException | InvalidKeyException |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024-2024 OnixByte.
* Copyright (C) 2024-2025 OnixByte.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,9 @@

package com.onixbyte.devkit.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
Expand Down Expand Up @@ -55,6 +58,8 @@
*/
public final class Base64Util {

private final static Logger log = LoggerFactory.getLogger(Base64Util.class);

/**
* Ensure that there is only one Base64 Encoder.
*
Expand Down
Loading

0 comments on commit 2efe577

Please sign in to comment.