freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

java加密技術(shù)非對(duì)稱加密算法rsa(編輯修改稿)

2025-08-09 20:37 本頁面
 

【文章內(nèi)容簡介】 gnature signature = (SIGNATURE_ALGORITHM)。 (priKey)。 (data)。 return encryptBASE64(())。 } /** * 校驗(yàn)數(shù)字簽名 * * @param data * 加密數(shù)據(jù) * @param publicKey * 公鑰 * @param sign * 數(shù)字簽名 * * @return 校驗(yàn)成功返回true 失敗返回false * @throws Exception * */ public static boolean verify(byte[] data, String publicKey, String sign) throws Exception { // 解密由base64編碼的公鑰 byte[] keyBytes = decryptBASE64(publicKey)。 // 構(gòu)造X509EncodedKeySpec對(duì)象 X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes)。 // KEY_ALGORITHM 指定的加密算法 KeyFactory keyFactory = (KEY_ALGORITHM)。 // 取公鑰匙對(duì)象 PublicKey pubKey = (keySpec)。 Signature signature = (SIGNATURE_ALGORITHM)。 (pubKey)。 (data)。 // 驗(yàn)證簽名是否正常 return (decryptBASE64(sign))。 } /** * 解密br * 用私鑰解密 * * @param data * @param key * @return * @throws Exception */ public static byte[] decryptByPrivateKey(byte[] data, String key) throws Exception { // 對(duì)密鑰解密 byte[] keyBytes = decryptBASE64(key)。 // 取得私鑰 PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes)。 KeyFactory keyFactory = (KEY_ALGORITHM)。 Key privateKey = (pkcs8KeySpec)。 // 對(duì)數(shù)據(jù)解密 Cipher cipher = (())。 (, privateKey)。 return (data)。 } /** * 解密br * 用私鑰解密 * * @param data * @param key * @return * @throws Exception */ public static byte[] decryptByPublicKey(byte[] data, String key) throws Exception { // 對(duì)密鑰解密 byte[] keyBytes = decryptBASE64(key)。 // 取得公鑰 X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes)。 KeyFactory keyFactory = (KEY_ALGORITHM)。 Key publicKey = (x509KeySpec)。 // 對(duì)數(shù)據(jù)解密 Cipher cipher = (())。 (, publicKey)。 return (data)。 } /** * 加密br * 用公鑰加密 * * @param data * @param key * @return * @throws Exception */ public static byte[] encryptByPublicKey(byte[] data, String key) throws Exception { // 對(duì)公鑰解密 byte[] keyBytes = decryptBASE64(key)。 // 取得公鑰 X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes)。 KeyFactory keyFactory = (KEY_ALGORITHM)。 Key publicKey = (x509KeySpec)。 // 對(duì)數(shù)據(jù)加密 Cipher cipher = (())。 (, publicKey)。 return (data)。 } /** * 加密br * 用私鑰加密 * * @param data * @param key * @return * @throws Exception */ public static byte[] encryptByPrivateKey(byte[] data, String key) throws Exception { // 對(duì)密鑰解密 byte[] keyBytes = decryptBASE64(key)。 // 取得私鑰 PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes)。 KeyFactory keyFactory = (KEY_ALGORITHM)。 Key privateKey = (pkcs8KeySpec)。 // 對(duì)數(shù)據(jù)加密 Cipher cipher = (())。 (, privateKey)。 return (data)。 } /** * 取得私鑰 * * @param keyMap * @return * @throws Exception */ public static String getPrivateKey(MapString, Object keyMap) throws Exception { Key key = (Key) (PRIVATE_KEY)。 return encryptBASE64(())。 } /** * 取得公鑰 * * @param keyMap * @return * @throws Exception */ public static String getPublicKey(MapString, Object keyMap) throws Exception { Key key = (Key) (PUBLIC_KEY)。 return encryptBASE64(())。 } /** * 初始化密鑰 * * @return * @throws Exception */ public static MapString, Object initKey() throws Exception { KeyPairGenerator keyPairGen = KeyPairGenerator .getInstance(KEY_ALGORITHM)。 (1024)。 KeyPair keyPair = ()。 // 公鑰 RSAPublicKey publicKey = (RSAPublicKey) ()。 // 私鑰 RSAPrivateKey privateKey = (RSAPrivateKey) ()。 MapString, Object keyMap = new HashMapString, Object(2)。 (PUBLIC_KEY, publicKey)。 (PRIVATE_KEY, privateKey)。 return keyMap。 }}再給出一個(gè)測(cè)試類: Java代碼 import static .*。 import 。 import 。 import 。 /** * * @author 梁棟 * @version * @since */ public class RSACoderTest { private String publicKey。 private String privateKey。 @Before public void setUp() throws Exception { MapString, Object keyMap = ()。 publicKey =
點(diǎn)擊復(fù)制文檔內(nèi)容
外語相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1