簡體   English   中英

Java:從編碼密鑰獲取密鑰

[英]Java: Get Key from encoded key

如何從編碼的byte []返回到java.security.Key?

import java.security.Key;
import javax.crypto.SecretKey;
import javax.crypto.KeyGenerator;

public class TestRSA {

    public static void main(String[] args) throws Exception {

    KeyGenerator kgen = KeyGenerator.getInstance("AES");
    kgen.init(128);
    SecretKey key = kgen.generateKey();
    byte[] encoded = key.getEncoded();

    // now, how to get back the Key object from the encoded byte[]?

    }
}

找到了! http://www.exampledepot.com/egs/javax.crypto/GetKeyBytes.html

抱歉給你帶來不便。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM