Search in sources :

Example 1 with SignBuilder

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

the class KeyPairTest method genSM2Key.

@Test
public void genSM2Key() throws BaseWeGooException {
    KeyBuilder builder = new KeyBuilder(new WeGooProvider());
    KeyPair keyPair = builder.buildKeyPair(KeyPairAlgEnum.SM2_256);
    System.out.println(Base64Util.encode(keyPair.getPrivate().getEncoded()));
    System.out.println(Base64Util.encode(keyPair.getPublic().getEncoded()));
    SignBuilder signBuilder = new SignBuilder(new WeGooProvider());
    byte[] signatureSourceData = signBuilder.signatureSourceData(SignAlgEnum.SM3_WITH_SM2, keyPair.getPrivate(), "sadfadf".getBytes(StandardCharsets.UTF_8));
    System.out.println(Base64Util.encode(signatureSourceData));
}
Also used : KeyBuilder(com.github.zhenwei.sdk.builder.KeyBuilder) SignBuilder(com.github.zhenwei.sdk.builder.SignBuilder) WeGooProvider(com.github.zhenwei.provider.jce.provider.WeGooProvider) Test(org.junit.Test)

Example 2 with SignBuilder

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

the class RealSignerTest method readSigner.

@Test
public void readSigner() throws BaseWeGooException {
    WeGooProvider weGooProvider = new WeGooProvider();
    SignBuilder signBuilder = new SignBuilder(weGooProvider);
    KeyBuilder keyBuilder = new KeyBuilder(weGooProvider);
    KeyPair keyPair = keyBuilder.buildKeyPair(KeyPairAlgEnum.RSA_1024);
    byte[] data = signBuilder.signatureSourceData(SignAlgEnum.SHA256_WITH_RSA, keyPair.getPrivate(), "asdfa".getBytes(StandardCharsets.UTF_8));
    System.out.println(Hex.toHexString(data));
}
Also used : KeyBuilder(com.github.zhenwei.sdk.builder.KeyBuilder) KeyPair(java.security.KeyPair) SignBuilder(com.github.zhenwei.sdk.builder.SignBuilder) WeGooProvider(com.github.zhenwei.provider.jce.provider.WeGooProvider) Test(org.junit.Test)

Aggregations

WeGooProvider (com.github.zhenwei.provider.jce.provider.WeGooProvider)2 KeyBuilder (com.github.zhenwei.sdk.builder.KeyBuilder)2 SignBuilder (com.github.zhenwei.sdk.builder.SignBuilder)2 Test (org.junit.Test)2 KeyPair (java.security.KeyPair)1