Search in sources :

Example 1 with BCRSAPublicKey

use of com.github.zhenwei.provider.jcajce.provider.asymmetric.rsa.BCRSAPublicKey in project LinLong-Java by zhenwei1108.

the class KeyPairTest method genRsa1024Key.

@Test
public void genRsa1024Key() throws BaseWeGooException {
    KeyBuilder builder = new KeyBuilder(new WeGooProvider());
    KeyPair keyPair = builder.buildKeyPair(KeyPairAlgEnum.RSA_1024);
    System.out.println(Base64Util.encode(keyPair.getPrivate().getEncoded()));
    System.out.println(Base64Util.encode(keyPair.getPublic().getEncoded()));
    BCRSAPublicKey aPublic = (BCRSAPublicKey) keyPair.getPublic();
    // 大素数
    System.out.println("modulus:" + aPublic.getModulus().toString());
    BigInteger mod = aPublic.getModulus().mod(BigInteger.valueOf(128));
    System.out.println(mod);
    // 指数
    System.out.println("exponent:" + aPublic.getPublicExponent().intValue());
}
Also used : KeyBuilder(com.github.zhenwei.sdk.builder.KeyBuilder) WeGooProvider(com.github.zhenwei.provider.jce.provider.WeGooProvider) BigInteger(java.math.BigInteger) BCRSAPublicKey(com.github.zhenwei.provider.jcajce.provider.asymmetric.rsa.BCRSAPublicKey) Test(org.junit.Test)

Aggregations

BCRSAPublicKey (com.github.zhenwei.provider.jcajce.provider.asymmetric.rsa.BCRSAPublicKey)1 WeGooProvider (com.github.zhenwei.provider.jce.provider.WeGooProvider)1 KeyBuilder (com.github.zhenwei.sdk.builder.KeyBuilder)1 BigInteger (java.math.BigInteger)1 Test (org.junit.Test)1