Why the generated key size is not constant?

Posted by Tom Brito on Stack Overflow See other posts from Stack Overflow or by Tom Brito
Published on 2010-06-01T14:49:28Z Indexed on 2010/06/01 14:53 UTC
Read the original article Hit count: 174

Filed under:
|
|

The following code prints randomly 634, 635, 636, each time I run it. Why its not constant?

public static void main(String[] args) throws Exception {
    KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA", "BC");
    keyPairGen.initialize(1024);
    RsaKeyPair keyPair = new RsaKeyPair(keyPairGen.generateKeyPair());
    System.out.println(keyPair.getPrivate().getEncoded().length);
}

© Stack Overflow or respective owner

Related posts about java

Related posts about encryption