国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

使用RSA生成公鑰和私鑰

這篇具有很好參考價(jià)值的文章主要介紹了使用RSA生成公鑰和私鑰。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

1.jdk keytool

可以用keytool工具直接生成,需要openssl工具Binaries - OpenSSLWiki設(shè)置到環(huán)境變量里

@echo off
cd ../output
IF exist auth.jks del auth.jks
IF exist auth.key del auth.key
keytool -genkeypair -alias xxxx_key -keyalg RSA -keypass xxxxxx -keystore auth.jks -storepass xxxxxx -dname CN=xxx
keytool -list -rfc --keystore auth.jks -storepass xxxxxx | openssl x509 -inform pem -pubkey > temp.key
(@FOR /f "tokens=1* delims=:" %%a IN ('findstr /n "^" "temp.key"') DO @IF %%a leq 9 ECHO(%%b) > auth.key
del temp.key
echo Build OK!
pause

?2.認(rèn)證與鑒權(quán)使用

生成的authkey放到gateway下,生成的auth.jks放到auth認(rèn)證服務(wù)下

網(wǎng)關(guān)結(jié)合鑒權(quán),需要配置如下配置文件????????????????

spring:
    security:
        oauth2:
            resourceserver:
                jwt:
                    public-key-location: classpath:auth.key

認(rèn)證服務(wù)配置Bean

    @Bean
    public JWKSource<SecurityContext> jwkSource() throws Exception {

        KeyStore keyStore = KeyStore.getInstance("JKS");
        // 取得JKS文件
        Resource resource = new ClassPathResource(DEFAULT_KEY_STORE_FILE);
        if (!resource.exists()) {
            resource = new FileSystemResource(DEFAULT_KEY_STORE_FILE);
        }
        try (InputStream inputStream = resource.getInputStream()) {
            keyStore.load(inputStream, DEFAULT_KEY_STORE_PASSWORD.toCharArray());
            RSAPublicKey publicKey = (RSAPublicKey) keyStore.getCertificate(DEFAULT_KEY_ALIAS).getPublicKey();
            RSAPrivateKey privateKey = (RSAPrivateKey) keyStore.getKey(DEFAULT_KEY_ALIAS, DEFAULT_KEY_PASSWORD.toCharArray());
            RSAKey rsaKey = new RSAKey.Builder(publicKey)
                    .privateKey(privateKey)
                    .keyStore(keyStore)
                    .build();
            JWKSet jwkSet = new JWKSet(rsaKey);
            return new ImmutableJWKSet<>(jwkSet);
        }
    }

3.工程項(xiàng)目直接生成

接口AuthToolController

package xxx.authtool.controller;

import xxx.authtool.util.RsaUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.security.KeyPair;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

@RestController
@RequestMapping("/generate")
public class AuthToolController {

    @Value("${file-path:}")
    private String filePath;

    /**
     * 創(chuàng)建并下載auth.key和auth.jks
     * @param days 創(chuàng)建證書的有效期 單位:天 不傳默認(rèn)90天
     * @param response http返回值
     * @throws IOException 異常
     */
    @GetMapping("/downloadAuthKeyZip")
    public void downloadAuthKeyZip(@RequestParam(required = false) Integer days, HttpServletResponse response) throws IOException {

        String dirPath = mkdir();
        // 創(chuàng)建一個(gè)臨時(shí)zip文件,用于存放要下載的多個(gè)文件
        File zipFile = new File(dirPath + "/" + "authKeys.zip");

        // 獲取需要下載的多個(gè)文件,并將它們添加到zip文件中
        List<File> filesToDownload = getFilesToDownload(dirPath, days);
        addFilesToZip(filesToDownload, zipFile);
        deleteFiles(filesToDownload);

        //設(shè)置響應(yīng)頭信息
        response.setContentType("application/zip");
        response.setHeader("Content-Disposition", "attachment; filename=authKeys.zip");

        // 將zip文件內(nèi)容寫入到HttpServletResponse輸出流中,實(shí)現(xiàn)文件下載
        try (InputStream inputStream = Files.newInputStream(zipFile.toPath());
             OutputStream outputStream = response.getOutputStream()) {
            byte[] buffer = new byte[4096];
            int length;
            while ((length = inputStream.read(buffer)) > 0) {
                outputStream.write(buffer, 0, length);
                outputStream.flush();
            }
        }
    }

    /**
     * 刪除文件
     * @param filesToDownload 文件列表
     */
    private void deleteFiles(List<File> filesToDownload) {
        for (File file : filesToDownload) {
            file.delete();
        }
    }

    /**
     * 獲取文件列表
     * @param dirPath 文件路徑
     * @param days 時(shí)間
     * @return 文件列表
     */
    private List<File> getFilesToDownload(String dirPath, Integer days) {
        // 獲取需要下載的多個(gè)文件
        List<File> files = new ArrayList<>();
        KeyPair keyPair = RsaUtil.genKeyPair();

        File publicFile = RsaUtil.genPublicFile(keyPair, dirPath);
        File privateFile = RsaUtil.genPrivateFile(keyPair, dirPath, days);

        files.add(publicFile);
        files.add(privateFile);
        return files;
    }


    /**
     * 壓縮文件
     * @param filesToDownload 文件列表
     * @param zipFile 壓縮文件
     * @throws IOException 異常
     */
    private void addFilesToZip(List<File> filesToDownload, File zipFile) throws IOException {
        // 將多個(gè)文件壓縮到zip文件中
        try (ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(zipFile.toPath()))) {
            for (File file : filesToDownload) {
                zipOutputStream.putNextEntry(new ZipEntry(file.getName()));
                try (FileInputStream inputStream = new FileInputStream(file)) {
                    byte[] buf = new byte[1024];
                    int len;
                    while ((len = inputStream.read(buf)) > 0) {
                        zipOutputStream.write(buf, 0, len);
                    }
                }
                zipOutputStream.closeEntry();
            }
        }
    }

    /**
     * 創(chuàng)建文件夾
     * @return 文件路徑
     */
    private String mkdir() {
        String dateString = getDateString();
        // 文件夾路徑
        String dirPath = filePath + "/" + dateString;

        File directory = new File(dirPath);
        // 判斷文件夾是否存在
        if (!directory.exists()) {
            // 創(chuàng)建文件夾及其父目錄
            directory.mkdirs();
        }
        return dirPath;
    }


    /**
     * 獲取日期字符串
     * @return 日期字符串
     */
    private String getDateString() {
        Date currentDate = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
        return dateFormat.format(currentDate);
    }
}

RSAUtil

package xxx.authtool.util;

import org.bouncycastle.cert.X509v3CertificateBuilder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.OperatorCreationException;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import sun.security.x509.X500Name;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.util.Date;

/**
 * RSA工具類
 *
 * @author xxx
 */
public final class RsaUtil {

    public static final String DEFAULT_KEY_STORE_FILE = "auth.jks";
    public static final String DEFAULT_KEY_FILE = "auth.key";

    public static final String DEFAULT_KEY_STORE_PASSWORD = "xxxxxx";

    public static final String DEFAULT_KEY_ALIAS = "xxxx";

    public static final String DEFAULT_KEY_PASSWORD = "xxxxxx";


    /**
     * 隨機(jī)生成密鑰對
     */
    public static KeyPair genKeyPair() {
        try {
            // KeyPairGenerator類用于生成公鑰和私鑰對,基于RSA算法生成對象
            KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
            // 初始化密鑰對生成器,密鑰大小為96-1024位
            keyPairGen.initialize(2048, new SecureRandom());
            // 生成一個(gè)密鑰對,保存在keyPair中
            return keyPairGen.generateKeyPair();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 生成私鑰
     * @param keyPair 密鑰對
     * @param dirPath 文件列表
     * @param days 時(shí)間
     * @return 秘鑰文件
     */
    public static File genPrivateFile(KeyPair keyPair, String dirPath, Integer days) {
        File file = new File(dirPath + "/" + DEFAULT_KEY_STORE_FILE);
        try (FileOutputStream fos = new FileOutputStream(file)) {
            KeyStore keyStore = KeyStore.getInstance("JKS");

            keyStore.load(null, DEFAULT_KEY_PASSWORD.toCharArray());
            // 得到私鑰
            PrivateKey privateKey = keyPair.getPrivate();
            // 為以下對象生成 2048 位RSA密鑰對和自簽名證書 (SHA256withRSA) (有效期為 90 天):
            String dn = "CN=xxxx";
            // 有效期默認(rèn)為 90 天
            int day = 90;
            if (days != null) {
                day = days;
            }
            X509v3CertificateBuilder builder = new JcaX509v3CertificateBuilder(
                    new X500Name(dn).asX500Principal(),
                    BigInteger.valueOf(System.currentTimeMillis()),
                    new Date(System.currentTimeMillis()),
                    new Date(System.currentTimeMillis() + day * 24 * 60 * 60 * 1000L),
                    new X500Name(dn).asX500Principal(),
                    keyPair.getPublic());

            ContentSigner signer =
                    new JcaContentSignerBuilder("SHA256withRSA").setProvider(new BouncyCastleProvider()).build(keyPair.getPrivate());

            Certificate cert = new JcaX509CertificateConverter().setProvider(new BouncyCastleProvider()).getCertificate(builder.build(signer));

            keyStore.setKeyEntry(DEFAULT_KEY_ALIAS, privateKey, DEFAULT_KEY_PASSWORD.toCharArray(), new Certificate[]{cert});

            keyStore.store(fos, DEFAULT_KEY_STORE_PASSWORD.toCharArray());
            return file;
        } catch (KeyStoreException | IOException | CertificateException | NoSuchAlgorithmException |
                 OperatorCreationException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 生成公鑰文件
     * @param keyPair 密鑰對
     * @param dirPath 文件列表
     * @return 公鑰文件
     */
    public static File genPublicFile(KeyPair keyPair, String dirPath) {
        try (StringWriter sw = new StringWriter()) {
            // 得到公鑰
            PublicKey publicKey = keyPair.getPublic();
            // 獲取PublicKey并將其轉(zhuǎn)換為PEM格式的字符串
            try (JcaPEMWriter pemWriter = new JcaPEMWriter(sw)) {
                pemWriter.writeObject(publicKey);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            File file = new File(dirPath + "/" + DEFAULT_KEY_FILE);

            try (FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
                 BufferedWriter bw = new BufferedWriter(fw)
            ) {
                bw.write(sw.toString());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return file;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

依賴

	implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
	implementation 'org.bouncycastle:bcpkix-jdk15on:1.69'

訪問localhost:6080/generate/downloadAuthKeyZip可獲取90天許可的證書

4.RSA工具類

package xxx.socket.stomp.config;

import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.spec.EncodedKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;

import org.springframework.util.Assert;

/**
 * RSA工具類
 *
 */
public class RsaUtils {

    private static String publicKeyStr = "";
    private static String privateKeyStr = "";

    public static void main(String[] args) {

        genKeyPair();

        String password = "xxxx";
        String rawPassword = encrypt(password);
        String password2 = decrypt(rawPassword);
        Assert.isTrue(password.equals(password2), "Error");
    }

    public static String encrypt(String password) {
        try {
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(Base64.getDecoder().decode(publicKeyStr));
            PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);

            Cipher cipher = Cipher.getInstance("RSA");
            cipher.init(Cipher.ENCRYPT_MODE, publicKey);
            byte[] passwordBytes = cipher.doFinal(password.getBytes(StandardCharsets.UTF_8));
            String result = new String(Base64.getEncoder().encode(passwordBytes), StandardCharsets.UTF_8);
            System.out.println("Encrypt Password: " + result);
            return result;
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            System.out.println("Algorithm Error\n" + e);
        } catch (NoSuchPaddingException | InvalidKeyException e) {
            System.out.println("Cipher Error\n" + e);
        } catch (IllegalBlockSizeException | BadPaddingException e) {
            System.out.println("Password Error\n" + e);
        }
        return null;
    }

    public static String decrypt(String password) {
        try {
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(privateKeyStr));
            PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);

            Cipher cipher = Cipher.getInstance("RSA");
            cipher.init(Cipher.DECRYPT_MODE, privateKey);
            byte[] passwordBytes = cipher.doFinal(Base64.getDecoder().decode(password.getBytes(StandardCharsets.UTF_8)));
            String result = new String(passwordBytes, StandardCharsets.UTF_8);
            System.out.println("Decrypt Password: " + result);
            return result;
        } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
            System.out.println("Algorithm Error\n" + e);
        } catch (NoSuchPaddingException | InvalidKeyException e) {
            System.out.println("Cipher Error\n" + e);
        } catch (IllegalBlockSizeException | BadPaddingException e) {
            System.out.println("Password Error\n" + e);
        }
        return null;
    }

    /**
     * 隨機(jī)生成密鑰對
     */
    public static void genKeyPair() {
        try {
            // KeyPairGenerator類用于生成公鑰和私鑰對,基于RSA算法生成對象
            KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
            // 初始化密鑰對生成器,密鑰大小為96-1024位
            keyPairGen.initialize(2048, new SecureRandom());
            // 生成一個(gè)密鑰對,保存在keyPair中
            KeyPair keyPair = keyPairGen.generateKeyPair();
            // 得到私鑰
            PrivateKey privateKey = keyPair.getPrivate();
            // 得到公鑰
            PublicKey publicKey = keyPair.getPublic();

            String publicKeyString = new String(Base64.getEncoder().encode(publicKey.getEncoded()));
            // 得到私鑰字符串
            String privateKeyString = new String(Base64.getEncoder().encode((privateKey.getEncoded())));
            System.out.println("隨機(jī)生成的公鑰為:" + publicKeyString);
            System.out.println("隨機(jī)生成的私鑰為:" + privateKeyString);
            publicKeyStr = publicKeyString;
            privateKeyStr = privateKeyString;
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
}

5. 參考資料

www.php1.cn/detail/Java_ShiYong_key_81410199.html文章來源地址http://www.zghlxwxcb.cn/news/detail-524529.html

到了這里,關(guān)于使用RSA生成公鑰和私鑰的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • RSA雙向加解密(公鑰加密-私鑰解密;私鑰加密-公鑰解密)

    ??????? 非對稱加密算法中,提供一個(gè)公鑰一個(gè)私鑰。一般情況下,采用公鑰加密、私鑰解密的方式。 ??????? 假設(shè)有這樣一個(gè)場景:服務(wù)A與服務(wù)B需要通信,通信內(nèi)容為了安全需要進(jìn)行加密傳輸,并且服務(wù)A與服務(wù)B不能互相持有對方的鑰匙。 ??????? 我首先想到的是

    2024年02月11日
    瀏覽(101)
  • Java RSA加解密-非對稱加密-公鑰私鑰加解密(使用hutool工具)

    Java RSA加解密-非對稱加密-公鑰私鑰加解密(使用hutool工具)

    之前一篇帖子(https://blog.csdn.net/u014137486/article/details/136413532)展示了使用原生Java進(jìn)行RSA加解密,本文介紹下使用當(dāng)下流行的Hutool工具進(jìn)行RSA加解密的用法。 目錄 一、在Linux環(huán)境下生成公鑰、私鑰文件 二、將生成的公私鑰文件導(dǎo)入項(xiàng)目中并移除pem文件的前后公私鑰標(biāo)記 三、po

    2024年04月23日
    瀏覽(376)
  • Windows生成公鑰和私鑰

    Windows生成公鑰和私鑰

    如果沒有.ssh文件夾,解決辦法參考如下 https://blog.csdn.net/m0_53721382/article/details/128666297 注:可以使用cmder軟件查看公鑰內(nèi)容(cmder的命令和linux一樣) 注:cmder添加到右鍵的方法,在Windows下使用管理員身份運(yùn)行cmd,然后執(zhí)行下列命令即可看到右鍵菜單中多了cmder here

    2024年02月16日
    瀏覽(103)
  • openssl3.2 - 檢查rsa證書和私鑰是否匹配(快速手搓一個(gè)工具)

    openssl3.2 - 檢查rsa證書和私鑰是否匹配(快速手搓一個(gè)工具)

    在學(xué)習(xí)openssl官方的/test/certs的腳本實(shí)現(xiàn), 做到第30個(gè)腳本實(shí)驗(yàn)時(shí), 發(fā)現(xiàn)根CA證書和key不匹配. 估計(jì)做實(shí)驗(yàn)時(shí), 遇到腳本需要的文件, 就隨便拷貝一個(gè)同名的文件過來, 導(dǎo)致證書和key不是一個(gè)腳本產(chǎn)生的, 所以不匹配 就想從前面的實(shí)驗(yàn)中, 找出匹配的證書和key來做實(shí)驗(yàn), 肯定有啊. 這事

    2024年01月24日
    瀏覽(93)
  • 已知RSA的公鑰(e,n)計(jì)算對應(yīng)的私鑰d

    已知RSA的公鑰(e,n)計(jì)算對應(yīng)的私鑰d

    今天分享一個(gè)軟考中經(jīng)常出現(xiàn)的關(guān)于RSA私鑰計(jì)算的題目。我們試著理解背后的算法邏輯,然后再看看如何解題。 設(shè)在RSA的公鑰密碼體制中,公鑰為(e, n)= (13, 35), 則私鑰d= ()。? A. 17 B. 15 C. 13 D. 11 Rivest Shamir Adleman(RSA)加密算法是一種非對稱加密算法,廣泛應(yīng)用于許多產(chǎn)

    2023年04月18日
    瀏覽(21)
  • C#.NET Framework RSA 公鑰加密 私鑰解密 ver:20230609

    C#.NET Framework RSA 公鑰加密 私鑰解密 ver:20230609 ? 環(huán)境說明: .NET Framework 4.6 的控制臺(tái)程序?。 ? .NET Framework?對于RSA的支持: 1.?.NET Framework 內(nèi)置只支持XML格式的私鑰/公鑰。如果要用PKCS1,PKCS8格式的,要用到三方庫BouncyCastle。 2. .NET 中默認(rèn)加密算法為“RSA/ECB/PKCS1Padding” ,要和

    2024年02月08日
    瀏覽(119)
  • C# .NET CORE .NET6 RSA 公鑰加密 私鑰解密

    環(huán)境說明: .NET CORE 版本:.NET 6 。 ? .NET CORE 對于RSA的支持: 1. .NET 6 中內(nèi)置了對 PKCS1,PKCS8 2種私鑰格式的支持。 2. 如果你要部署在Linux,docker ,k8s 中;一定要用 “RSA”這個(gè)類,不能是 .NET FRAMEWORK 的?RSACryptoServiceProvider。 3. .NET 中默認(rèn)加密算法為“RSA/ECB/PKCS1Padding” ,要和JAVA互通

    2024年02月08日
    瀏覽(95)
  • RSA加解密工具類(PKCS8公鑰加密,PKCS1私鑰解密)

    RSA加解密工具類(PKCS8公鑰加密,PKCS1私鑰解密)

    場景 :如果項(xiàng)目上生成的秘鑰,公鑰是PKCS8格式,私鑰卻是PKCS1格式。需要在這種場景加解密的話可以直接使用下面工具類。 特殊說明:私鑰解密的時(shí)候必須把私鑰源文件內(nèi)容整個(gè)傳入,不能刪除私鑰的文件頭和文件尾,并且不能刪除換行。

    2024年02月11日
    瀏覽(82)
  • 使用 OpenSSL 擴(kuò)展來實(shí)現(xiàn)公鑰和私鑰加密

    首先,你需要生成一對公鑰和私鑰??梢允褂?OpenSSL 工具來生成: 1、生成私鑰 2、從私鑰生成公鑰: 現(xiàn)在你有了一個(gè)私鑰( private_key.pem )和一個(gè)對應(yīng)的公鑰( public_key.pem )。下面是如何在 PHP 中使用它們進(jìn)行加密和解密: 3、檢測是否支付OPENSSL,或用phpinfo(); 上述代碼中,

    2024年02月03日
    瀏覽(90)
  • jdk 中的 keytool 的使用,以及提取 jks 文件中的公鑰和私鑰

    jdk 中的 keytool 的使用,以及提取 jks 文件中的公鑰和私鑰

    這里暫時(shí)只需要知道如何使用就可以了。 首先是生成一個(gè)密鑰, 解釋一下這里的選項(xiàng), -alias 密鑰對的名稱 -keypass 密鑰密碼 -validity 有效期,這里是以天為單位 -storepass 存儲(chǔ)庫的密碼 -keystore 指定生成的密鑰文件存放的位置,這里的? fanyfull.jks ?表示的是當(dāng)前目錄下的? fan

    2024年02月08日
    瀏覽(111)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包