Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,10 @@ void decryptThrowsExceptionForNullCipherText() {
@Test
void encryptAndDecryptWithUnicodeCharacters() throws Exception {
String plainText = "你好,世界!🌍";
System.out.println("Original plain text: " + plainText);
PublicKey publicKey = keyPair.getPublic();
PrivateKey privateKey = keyPair.getPrivate();

String encryptedText = SM2EncryptionUtil.encrypt(plainText, publicKey);
System.out.println("Encrypted text: " + encryptedText);
assertNotNull(encryptedText, "Encrypted text should not be null");

String decryptedText = SM2EncryptionUtil.decrypt(encryptedText, privateKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import org.junit.jupiter.api.*;
import org.mockito.MockitoAnnotations;

import java.security.KeyPair;

import java.util.Locale;

import static org.junit.jupiter.api.Assertions.*;

Expand Down Expand Up @@ -240,7 +241,7 @@ void sm3HashOutputIsLowercaseHex() throws Exception {
String hash = SM3PasswordUtil.sm3Hash("test", "salt");
assertTrue(hash.matches("^[0-9a-f]{64}$"));
// 确保没有大写字母
assertEquals(hash, hash.toLowerCase());
assertEquals(hash, hash.toLowerCase(Locale.ROOT));
}

@Test
Expand Down Expand Up @@ -454,9 +455,7 @@ void sm3ConsistencyWithKnownVectors() throws Exception {
String hash2 = SM3PasswordUtil.sm3Hash(input, salt);
assertEquals(hash1, hash2, "相同输入应得到相同哈希");

// 可选:如果有预置的权威向量,可取消注释验证
// String expected = "66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0";
// assertEquals(expected, hash1);

}

// 4. 密码为空字符串时的特殊处理(盐值生成和验证)
Expand Down
Loading