Search in sources :

Example 1 with HashBuilder

use of com.github.zhenwei.sdk.builder.HashBuilder in project LinLong-Java by zhenwei1108.

the class RealHashTest method sm3Digest.

@Test
public void sm3Digest() throws BaseWeGooException {
    WeGooProvider provider = new WeGooProvider();
    HashBuilder builder = new HashBuilder(provider);
    byte[] source = "asdf".getBytes(StandardCharsets.UTF_8);
    byte[] digest = builder.digest(DigestAlgEnum.SM3, source);
    System.out.println(Hex.toHexString(digest));
    // 公钥参与运算
    KeyBuilder keyBuilder = new KeyBuilder(provider);
    KeyPair keyPair = keyBuilder.buildKeyPair(KeyPairAlgEnum.SM2_256);
    DigestParams digestParams = new DigestParams(keyPair.getPublic());
    digest = builder.digest(DigestAlgEnum.SM3, source, digestParams);
    System.out.println(Hex.toHexString(digest));
}
Also used : KeyBuilder(com.github.zhenwei.sdk.builder.KeyBuilder) KeyPair(java.security.KeyPair) WeGooProvider(com.github.zhenwei.provider.jce.provider.WeGooProvider) HashBuilder(com.github.zhenwei.sdk.builder.HashBuilder) DigestParams(com.github.zhenwei.sdk.builder.params.DigestParams) Test(org.junit.Test)

Aggregations

WeGooProvider (com.github.zhenwei.provider.jce.provider.WeGooProvider)1 HashBuilder (com.github.zhenwei.sdk.builder.HashBuilder)1 KeyBuilder (com.github.zhenwei.sdk.builder.KeyBuilder)1 DigestParams (com.github.zhenwei.sdk.builder.params.DigestParams)1 KeyPair (java.security.KeyPair)1 Test (org.junit.Test)1