From 58b6f863bd13d00fc6d4332445020e7cac1653fe Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Tue, 18 Oct 2022 16:26:36 +0800 Subject: [PATCH] =?UTF-8?q?/encrypt=20=E6=B7=BB=E5=8A=A0=20base64=20?= =?UTF-8?q?=E5=AF=B9=20base64url=20=E6=A0=BC=E5=BC=8F=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../sukazyo/cono/morny/GradleProjectConfigures.java | 4 ++-- .../cc/sukazyo/cono/morny/bot/command/Encryptor.java | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5576ec9..9f8614b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ ## Core -VERSION = 0.8.0.8 +VERSION = 0.8.0.9 CODENAME = putian diff --git a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java index 2c188e6..4d26476 100644 --- a/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java +++ b/src/main/java/cc/sukazyo/cono/morny/GradleProjectConfigures.java @@ -4,7 +4,7 @@ package cc.sukazyo.cono.morny; * the final field that will be updated by gradle automatically. */ public class GradleProjectConfigures { - public static final String VERSION = "0.8.0.8"; + public static final String VERSION = "0.8.0.9"; public static final String CODENAME = "putian"; - public static final long COMPILE_TIMESTAMP = 1665999835121L; + public static final long COMPILE_TIMESTAMP = 1666081545158L; } diff --git a/src/main/java/cc/sukazyo/cono/morny/bot/command/Encryptor.java b/src/main/java/cc/sukazyo/cono/morny/bot/command/Encryptor.java index 485a562..e770b9f 100644 --- a/src/main/java/cc/sukazyo/cono/morny/bot/command/Encryptor.java +++ b/src/main/java/cc/sukazyo/cono/morny/bot/command/Encryptor.java @@ -39,7 +39,9 @@ public class Encryptor implements ITelegramCommand { MornyCoeur.extra().exec(new SendMessage( event.message().chat().id(), """ base64, b64 + base64url, base64u, b64u base64decode, base64d, b64d + base64url-decode, base64ud, b64ud sha1 sha256 sha512 @@ -132,8 +134,9 @@ public class Encryptor implements ITelegramCommand { byte[] result = null; String resultName = null; switch (command.getArgs()[0]) { - case "base64", "b64" -> { - result = Base64.getEncoder().encode(data); + case "base64", "b64", "base64url", "base64u", "b64u" -> { + final Base64.Encoder b64tool = command.getArgs()[0].contains("u") ? Base64.getUrlEncoder() : Base64.getEncoder(); + result = b64tool.encode(data); if (!inputText) { echoString = false; resultName = dataName+".b64.txt"; @@ -141,8 +144,9 @@ public class Encryptor implements ITelegramCommand { resultString = new String(result, CommonEncrypt.ENCRYPT_STANDARD_CHARSET); } } - case "base64decode", "base64d", "b64d" -> { - try { result = Base64.getDecoder().decode(data); } + case "base64decode", "base64d", "b64d", "base64url-decode", "base64ud", "b64ud" -> { + final Base64.Decoder b64tool = command.getArgs()[0].contains("u") ? Base64.getUrlDecoder() : Base64.getDecoder(); + try { result = b64tool.decode(data); } catch (IllegalArgumentException e) { MornyCoeur.extra().exec(new SendSticker( event.message().chat().id(), TelegramStickers.ID_404