packagecom.oscgc.securevideo.server.tool.rsa;importjava.io.IOException;importjava.io.StringWriter;import java.security.*;importjava.security.interfaces.RSAPrivateKey;importjava.security.interfaces.RSAPublicKey;importjava.security.spec.PKCS8EncodedKeySpec;importjava.security.spec.X509EncodedKeySpec;importorg.bouncycastle.openssl.PEMWriter;importorg.bouncycastle.util.io.pem.PemObject;/*** Created by Yq on 2015/6/10.*/
public classRsaKeyTools {public static final String PEM_PUBLICKEY = "PUBLIC KEY";public static final String PEM_PRIVATEKEY = "PRIVATE KEY";/*** generateRSAKeyPair
*
*@paramkeySize
*@return
*/
public static KeyPair generateRSAKeyPair(intkeySize) {
KeyPairGenerator generator= null;
SecureRandom random= newSecureRandom();
Security.addProvider(neworg.bouncycastle.jce.provider.BouncyCastleProvider());try{