Skip to content

ObfuscationUtils v1.2.0 - 图片混淆工具库

Pre-release
Pre-release

Choose a tag to compare

@2195517546 2195517546 released this 31 Dec 02:43

概述

ObfuscationUtils v1.2 现已完全支持异步操作。本次更新为所有的图片处理功能添加了异步 API,使得该库能够更好地适配高并发场景、响应式编程框架和现代异步应用架构。

实现内容

1. 核心异步组件

1.1 ObfuscationExecutor - 线程池管理器

位置: com.uiloalxise.async.ObfuscationExecutor

功能:

  • 提供默认线程池(固定大小 = CPU核心数 × 2)
  • 支持自定义线程池
  • 线程安全的单例模式
  • 优雅关闭机制

主要方法:

ExecutorService getExecutor()                    // 获取默认线程池
void setExecutor(ExecutorService executor)       // 设置自定义线程池
ExecutorService createExecutor(int poolSize)     // 创建独立线程池
void shutdown()                                  // 优雅关闭
void shutdownNow()                              // 立即关闭

1.2 AsyncImageData - 异步图片操作

位置: com.uiloalxise.async.AsyncImageData

功能:

  • 异步加载图片(文件、流、字节数组、MultipartFile)
  • 异步保存图片
  • 异步格式转换(转字节数组、转InputStream)
  • 支持自定义线程池

主要方法:

CompletableFuture<ImageData> fromFileAsync(String filePath)
CompletableFuture<ImageData> fromInputStreamAsync(InputStream is)
CompletableFuture<ImageData> fromBytesAsync(byte[] bytes)
CompletableFuture<ImageData> fromMultipartFileAsync(Object file)
CompletableFuture<Void> saveToFileAsync(ImageData data, String path)
CompletableFuture<byte[]> toBytesAsync(ImageData data)
CompletableFuture<InputStream> toInputStreamAsync(ImageData data)

1.3 AsyncUtil - 异步混淆工具

位置: com.uiloalxise.async.AsyncUtil

功能:

  • 为所有混淆算法提供异步版本
  • 支持自定义线程池
  • 与同步 API 完全对应

支持的算法:

  • Tomato 混淆(小番茄)
  • Block 混淆(方块)
  • RowPixel 混淆(行像素)
  • PerPixel 混淆(像素级)
  • PicEncryptRow 混淆(PE行)
  • PicEncryptRowColumn 混淆(PE行列)
  • Sort 混淆(排序)
  • Random 混淆(随机)

方法命名规范:

CompletableFuture<ImageData> {algorithm}EncryptAsync(String key, ImageData data)
CompletableFuture<ImageData> {algorithm}DecryptAsync(String key, ImageData data)

2. 抽象类增强

ImageObfuscation 抽象类

位置: com.uiloalxise.utils.base.ImageObfuscation

新增方法:

CompletableFuture<ImageData> processAsync(ProcessType type)
CompletableFuture<ImageData> processAsync(ProcessType type, ExecutorService executor)
CompletableFuture<ImageData> encryptAsync()
CompletableFuture<ImageData> encryptAsync(ExecutorService executor)
CompletableFuture<ImageData> decryptAsync()
CompletableFuture<ImageData> decryptAsync(ExecutorService executor)

继承效果:
所有继承 ImageObfuscation 的混淆类自动获得异步能力:

  • TomatoObfuscation
  • BlockObfuscation
  • RowPixelObfuscation
  • PerPixelObfuscation
  • PicEncryptRowObfuscation
  • PicEncryptRowColumnObfuscation
  • SortObfuscation
  • RandomObfuscation
  • XuanObfuscation