src/main/java/studio/baxia/fo/util/JCryptionUtil.java

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package studio.baxia.fo.util;
  
import org.bouncycastle.jce.provider.BouncyCastleProvider;

import java.security.GeneralSecurityException;
import java.security.KeyPair;  
import java.security.KeyPairGenerator;  
import java.security.NoSuchAlgorithmException;  
import java.security.Provider;
import java.security.interfaces.RSAPublicKey;  
  


import javax.crypto.Cipher;  


public class JCryptionUtil {  
      
    public static final Provider provider = new BouncyCastleProvider();
    /** 
     * Constructor 
     */  
    public JCryptionUtil() throws Exception {  
        java.security.Security.addProvider(provider);  
    }  
  
    /** 
     * Generates the Keypair with the given keyLength. 
     *  
     * @param keyLength 
     *            length of key 
     * @return KeyPair object 
     * @throws RuntimeException 
     *             if the RSA algorithm not supported 
     */  
    public KeyPair generateKeypair(int keyLength) throws Exception {  
        try {  
            KeyPairGenerator kpg;   
            try {  
                kpg = KeyPairGenerator.getInstance("RSA");  
            } catch (Exception e) {  
                kpg = KeyPairGenerator.getInstance("RSA",provider);  
            }  
            kpg.initialize(keyLength);  
            KeyPair keyPair = kpg.generateKeyPair();  
            return keyPair;  
        } catch (NoSuchAlgorithmException e1) {  
            throw new RuntimeException("RSA algorithm not supported", e1);  
        } catch (Exception e) {  
            throw new Exception("other exceptions", e);  
        }  
    }  
  
    /** 
     * Decrypts a given string with the RSA keys 
     *  
     * @param encrypted 
     *            full encrypted text 
     * @param keys 
     *            RSA keys 
后面还有 104 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。