java加密类

java.security.KeyStore
KeyStore ks = KeyStore.getInstance(type);
KeyStore ks = KeyStore.getInstance(type);
KeyStore ks = KeyStore.getInstance("PKCS12");
ks.load(fis, nPassword)
load(InputStream stream, char[] password)
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
load(InputStream stream, char[] password)

java.security.KeyStore
certKeyStoreMap.get(certPath).aliases()
public final Key getKey(String alias, char[] password)
PrivateKey privateKey = (PrivateKey) certKeyStoreMap.get(certPath)
                    .getKey(keyAlias, certPwd.toCharArray());
public static byte[] signBySoft(PrivateKey privateKey, byte[] data)
    throws Exception {
    byte[] result = null;
    Signature st = Signature.getInstance(BC_PROV_ALGORITHM_SHA256RSA);
    st.initSign(privateKey);
    st.update(data);
    result = st.sign();
    String s = Base64.encodeBase64String(result);
    System.out.println(s);
    return result;
}
org.apache.commons.codec.binary.Base64
String signStr = Base64.encode(byteSign);
com.ning.http.util.Base64
<dependency>
    <groupId>com.ning</groupId>
    <artifactId>async-http-client</artifactId>
    <version>1.8.13</version>
</dependency>
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-jdk15on</artifactId>
    <version>1.59</version>
</dependency>

猜你喜欢

转载自www.cnblogs.com/mozq/p/11831472.html
今日推荐