v 5.0.9
This commit is contained in:
+5
-5
@@ -15,8 +15,8 @@
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base10.kt
|
||||
* LastUpdate 2026-02-08 03:08:10
|
||||
* CurrentFile Base10Codec.kt
|
||||
* LastUpdate 2026-03-12 10:34:36
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -24,11 +24,11 @@ package com.mingliqiye.utils.base
|
||||
|
||||
import java.math.BigInteger
|
||||
|
||||
internal class Base10 : BaseCodec {
|
||||
internal class Base10Codec : BaseCodec {
|
||||
|
||||
/**
|
||||
* 将字节数组编码为Base10字符串(十进制)
|
||||
*
|
||||
*
|
||||
* @param bytes 需要编码的字节数组
|
||||
* @return 编码后的Base10字符串(十进制数字)
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ internal class Base10 : BaseCodec {
|
||||
|
||||
/**
|
||||
* 将Base10字符串解码为字节数组
|
||||
*
|
||||
*
|
||||
* @param string 需要解码的Base10字符串(十进制数字)
|
||||
* @return 解码后的字节数组
|
||||
*/
|
||||
+3
-3
@@ -15,8 +15,8 @@
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base16.kt
|
||||
* LastUpdate 2026-02-08 03:08:10
|
||||
* CurrentFile Base16Codec.kt
|
||||
* LastUpdate 2026-03-12 10:34:36
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,7 @@ package com.mingliqiye.utils.base
|
||||
* Base16编解码器实现类
|
||||
* 提供字节数组与十六进制字符串之间的相互转换功能
|
||||
*/
|
||||
internal class Base16 : BaseCodec {
|
||||
internal class Base16Codec : BaseCodec {
|
||||
/**
|
||||
* 将字节数组编码为十六进制字符串
|
||||
* @param bytes 待编码的字节数组
|
||||
+3
-3
@@ -15,8 +15,8 @@
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base256.kt
|
||||
* LastUpdate 2026-02-08 03:08:10
|
||||
* CurrentFile Base256Codec.kt
|
||||
* LastUpdate 2026-03-12 10:34:36
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ package com.mingliqiye.utils.base
|
||||
* !#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~§±×÷←↑→↓⇒⇔∀∃∅∆∇∈∉∋∌∏∑−∓∕∗∘∙√∛∜∞∟∠∣∥∧∨∩∪∫∬∭∮∯∰∱∲∳∴∵∶∷≈≠≡≤≥≦≧≪≫≺≻⊂⊃⊆⊇⊈⊉⊊⊋⊕⊖⊗⊘⊙⊚⊛⊜⊝⊞⊟⊠⊡⊢⊣⊤⊥⊦⊧⊨⊩⊪⊫⊬⊭⊮⊯⋀⋁⋂⋃⋄⋅⋆⋇⋈⋉⋊⋋⋌⋍⋎⋏⋐⋑⋒⋓⋔⋕⋖⋗⋘⋙⋚⋛⋜⋝⋞⋟⋠⋡⋢⋣⋤⋥⋦⋧⋨⋩▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙
|
||||
*
|
||||
*/
|
||||
internal class Base256 : BaseCodec {
|
||||
internal class Base256Codec : BaseCodec {
|
||||
|
||||
companion object {
|
||||
val code = arrayOf(
|
||||
+3
-3
@@ -15,14 +15,14 @@
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base2.kt
|
||||
* LastUpdate 2026-02-08 03:06:23
|
||||
* CurrentFile Base2Codec.kt
|
||||
* LastUpdate 2026-03-12 10:34:36
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.base
|
||||
|
||||
internal class Base2 : BaseCodec {
|
||||
internal class Base2Codec : BaseCodec {
|
||||
override fun encode(bytes: ByteArray): String {
|
||||
if (bytes.isEmpty()) return ""
|
||||
val result = StringBuilder()
|
||||
+9
-7
@@ -15,30 +15,32 @@
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base64.kt
|
||||
* LastUpdate 2026-02-08 03:08:10
|
||||
* CurrentFile Base64Codec.kt
|
||||
* LastUpdate 2026-03-12 10:34:36
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.base
|
||||
|
||||
import java.util.*
|
||||
|
||||
/*
|
||||
* Base64编解码工具类
|
||||
* 提供Base64编码和解码功能的实现
|
||||
*/
|
||||
internal class Base64 : BaseCodec {
|
||||
internal class Base64Codec : BaseCodec {
|
||||
|
||||
/*
|
||||
* Base64编码器实例
|
||||
* 用于执行字节数组到Base64字符串的编码操作
|
||||
*/
|
||||
val BASE_64_ENCODER: java.util.Base64.Encoder = java.util.Base64.getEncoder()
|
||||
val encoder: Base64.Encoder = Base64.getEncoder()
|
||||
|
||||
/*
|
||||
* Base64解码器实例
|
||||
* 用于执行Base64字符串到字节数组的解码操作
|
||||
*/
|
||||
val BASE_64_DECODER: java.util.Base64.Decoder = java.util.Base64.getDecoder()
|
||||
val decoder: Base64.Decoder = Base64.getDecoder()
|
||||
|
||||
/*
|
||||
* 将字节数组编码为Base64字符串
|
||||
@@ -47,7 +49,7 @@ internal class Base64 : BaseCodec {
|
||||
* @return 编码后的Base64字符串
|
||||
*/
|
||||
override fun encode(bytes: ByteArray): String {
|
||||
return BASE_64_ENCODER.encodeToString(bytes)
|
||||
return encoder.encodeToString(bytes)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -57,6 +59,6 @@ internal class Base64 : BaseCodec {
|
||||
* @return 解码后的字节数组
|
||||
*/
|
||||
override fun decode(string: String): ByteArray {
|
||||
return BASE_64_DECODER.decode(string)
|
||||
return decoder.decode(string)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2026 mingliqiye
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base64UrlCodec.kt
|
||||
* LastUpdate 2026-03-12 10:34:36
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.base
|
||||
|
||||
import java.util.*
|
||||
|
||||
internal class Base64UrlCodec : BaseCodec {
|
||||
|
||||
/*
|
||||
* Base64编码器实例
|
||||
* 用于执行字节数组到Base64字符串的编码操作
|
||||
*/
|
||||
val encoder: Base64.Encoder = Base64.getUrlEncoder()
|
||||
|
||||
/*
|
||||
* Base64解码器实例
|
||||
* 用于执行Base64字符串到字节数组的解码操作
|
||||
*/
|
||||
val decoder: Base64.Decoder = Base64.getUrlDecoder()
|
||||
|
||||
/*
|
||||
* 将字节数组编码为Base64字符串
|
||||
*
|
||||
* @param bytes 待编码的字节数组
|
||||
* @return 编码后的Base64字符串
|
||||
*/
|
||||
override fun encode(bytes: ByteArray): String {
|
||||
return encoder.encodeToString(bytes)
|
||||
}
|
||||
|
||||
/*
|
||||
* 将Base64字符串解码为字节数组
|
||||
*
|
||||
* @param string 待解码的Base64字符串
|
||||
* @return 解码后的字节数组
|
||||
*/
|
||||
override fun decode(string: String): ByteArray {
|
||||
return decoder.decode(string)
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -15,8 +15,8 @@
|
||||
*
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile Base91.kt
|
||||
* LastUpdate 2026-02-08 03:08:10
|
||||
* CurrentFile Base91Codec.kt
|
||||
* LastUpdate 2026-03-12 10:34:36
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -27,7 +27,7 @@ package com.mingliqiye.utils.base
|
||||
*
|
||||
* Base91 是一种高效的二进制到文本的编码方式,相较于 Base64,它使用更少的字符来表示相同的数据。
|
||||
*/
|
||||
internal class Base91 : BaseCodec {
|
||||
internal class Base91Codec : BaseCodec {
|
||||
|
||||
companion object {
|
||||
/**
|
||||
@@ -16,27 +16,21 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile BaseType.kt
|
||||
* LastUpdate 2026-02-09 19:54:38
|
||||
* LastUpdate 2026-03-12 10:08:42
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
package com.mingliqiye.utils.base
|
||||
|
||||
import com.mingliqiye.utils.base.code.Base10
|
||||
import com.mingliqiye.utils.base.code.Base16
|
||||
import com.mingliqiye.utils.base.code.Base2
|
||||
import com.mingliqiye.utils.base.code.Base256
|
||||
import com.mingliqiye.utils.base.code.Base64
|
||||
import com.mingliqiye.utils.base.code.Base91
|
||||
|
||||
enum class BaseType(val baseCodec: BaseCodec) : BaseCodec {
|
||||
|
||||
BASE2(Base2),
|
||||
BASE10(Base10),
|
||||
BASE16(Base16),
|
||||
BASE64(Base64),
|
||||
BASE91(Base91),
|
||||
BASE256(Base256);
|
||||
BASE2(com.mingliqiye.utils.base.code.BASE2),
|
||||
BASE10(com.mingliqiye.utils.base.code.BASE10),
|
||||
BASE16(com.mingliqiye.utils.base.code.BASE16),
|
||||
BASE64(com.mingliqiye.utils.base.code.BASE64),
|
||||
BASE64URL(com.mingliqiye.utils.base.code.BASE64URL),
|
||||
BASE91(com.mingliqiye.utils.base.code.BASE91),
|
||||
BASE256(com.mingliqiye.utils.base.code.BASE256);
|
||||
|
||||
override fun encode(bytes: ByteArray) = baseCodec.encode(bytes)
|
||||
override fun decode(string: String) = baseCodec.decode(string)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* ProjectName mingli-utils
|
||||
* ModuleName mingli-utils.main
|
||||
* CurrentFile BaseCodes.kt
|
||||
* LastUpdate 2026-02-08 03:10:03
|
||||
* LastUpdate 2026-03-12 10:03:32
|
||||
* UpdateUser MingLiPro
|
||||
*/
|
||||
|
||||
@@ -30,52 +30,57 @@ import com.mingliqiye.utils.base.*
|
||||
* 提供Base2编码器的懒加载实例。
|
||||
* 该编码器用于将数据编码为二进制格式。
|
||||
*/
|
||||
@get:JvmName("Base2")
|
||||
val Base2: BaseCodec by lazy {
|
||||
Base2()
|
||||
@get:JvmName("base2")
|
||||
val BASE2: BaseCodec by lazy {
|
||||
Base2Codec()
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供Base10编码器的懒加载实例。
|
||||
* 该编码器用于将数据编码为十进制格式。
|
||||
*/
|
||||
@get:JvmName("Base10")
|
||||
val Base10: BaseCodec by lazy {
|
||||
Base10()
|
||||
@get:JvmName("base10")
|
||||
val BASE10: BaseCodec by lazy {
|
||||
Base10Codec()
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供Base16编码器的懒加载实例。
|
||||
* 该编码器用于将数据编码为十六进制格式。
|
||||
*/
|
||||
@get:JvmName("Base16")
|
||||
val Base16: BaseCodec by lazy {
|
||||
Base16()
|
||||
@get:JvmName("base16")
|
||||
val BASE16: BaseCodec by lazy {
|
||||
Base16Codec()
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供Base64编码器的懒加载实例。
|
||||
* 该编码器用于将数据编码为Base64格式,常用于URL安全传输或存储。
|
||||
*/
|
||||
@get:JvmName("Base64")
|
||||
val Base64: BaseCodec by lazy {
|
||||
Base64()
|
||||
@get:JvmName("base64")
|
||||
val BASE64: BaseCodec by lazy {
|
||||
Base64Codec()
|
||||
}
|
||||
|
||||
@get:JvmName("base64Url")
|
||||
val BASE64URL: BaseCodec by lazy {
|
||||
Base64UrlCodec()
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供Base91编码器的懒加载实例。
|
||||
* 该编码器用于将数据编码为Base91格式,具有较高的压缩效率。
|
||||
*/
|
||||
@get:JvmName("Base91")
|
||||
val Base91: BaseCodec by lazy {
|
||||
Base91()
|
||||
@get:JvmName("base91")
|
||||
val BASE91: BaseCodec by lazy {
|
||||
Base91Codec()
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供Base256编码器的懒加载实例。
|
||||
* 该编码器用于将数据编码为Base256格式,适用于字节级数据处理。
|
||||
*/
|
||||
@get:JvmName("Base256")
|
||||
val Base256: BaseCodec by lazy {
|
||||
Base256()
|
||||
@get:JvmName("base256")
|
||||
val BASE256: BaseCodec by lazy {
|
||||
Base256Codec()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user