Skip to content

Commit

Permalink
fix rsa bug
Browse files Browse the repository at this point in the history
Signed-off-by: wmqwxb <[email protected]>
  • Loading branch information
wmqwxb committed Dec 21, 2023
1 parent 96601a7 commit 5098fc1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean checkUser(String username, String password) {
String privateKey = getValue("server.board.encrypt.private_key");
String encrypted = getValue("server.board.encrypt.enable");
if ("true".equalsIgnoreCase(encrypted)) {
if (StringUtils.isNotBlank(privateKey)) {
if (StringUtils.isBlank(privateKey)) {
return false;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
Expand Down Expand Up @@ -149,7 +150,7 @@ public static String decryptByPrivateKey(String encryptedDataStr, String private
}
byte[] decryptedData = out.toByteArray();
out.close();
return new String(decryptedData);
return new String(decryptedData, StandardCharsets.UTF_8).trim();
}

/**
Expand Down

0 comments on commit 5098fc1

Please sign in to comment.