mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
6b95a60c4b
commit
86442f35c8
@ -24,6 +24,18 @@ import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* ULID(Universally Unique Lexicographically Sortable Identifier)通用唯一词典分类标识符,特性:
|
||||
* <ul>
|
||||
* <li>与UUID的128位兼容性</li>
|
||||
* <li>每毫秒1.21e + 24个唯一ULID</li>
|
||||
* <li>按字典顺序(也就是字母顺序)排序</li>
|
||||
* <li>规范地编码为26个字符串,而不是UUID的36个字符</li>
|
||||
* <li>使用Crockford的base32获得更好的效率和可读性(每个字符5位)</li>
|
||||
* <li>不区分大小写</li>
|
||||
* <li>没有特殊字符(URL安全)</li>
|
||||
* <li>单调排序顺序(正确检测并处理相同的毫秒)</li>
|
||||
* </ul>
|
||||
*
|
||||
* 参考:https://github.com/zjcscut/framework-mesh/blob/master/ulid4j/src/main/java/cn/vlts/ulid/ULID.java
|
||||
* <pre>{@code
|
||||
* 01AN4Z07BY 79KA1307SR9X4MV3
|
||||
@ -32,7 +44,7 @@ import java.util.Random;
|
||||
* 48bits 80bits
|
||||
* }</pre>
|
||||
*
|
||||
* @author throwable
|
||||
* @author throwable,Looly
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class ULID implements Comparable<ULID>, Serializable {
|
||||
|
@ -0,0 +1,27 @@
|
||||
package org.dromara.hutool.crypto;
|
||||
|
||||
import org.bouncycastle.jce.interfaces.ECPrivateKey;
|
||||
import org.bouncycastle.jce.interfaces.ECPublicKey;
|
||||
import org.bouncycastle.math.ec.ECPoint;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyPair;
|
||||
|
||||
public class IssueI99FKETest {
|
||||
@Test
|
||||
void getSm2KeyTest() {
|
||||
final KeyPair pair = KeyUtil.generateKeyPair("SM2");
|
||||
final ECPrivateKey aPrivate = (ECPrivateKey) pair.getPrivate();
|
||||
final BigInteger d = aPrivate.getD();
|
||||
Assertions.assertNotNull(d);
|
||||
|
||||
final ECPublicKey aPublic = (ECPublicKey) pair.getPublic();
|
||||
final ECPoint point = aPublic.getQ();
|
||||
final BigInteger x = point.getXCoord().toBigInteger();
|
||||
final BigInteger y = point.getYCoord().toBigInteger();
|
||||
Assertions.assertNotNull(x);
|
||||
Assertions.assertNotNull(y);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user