开发者

Java: Get Key from encoded key

开发者 https://www.devze.com 2022-12-26 10:35 出处:网络
How to get back from encoded byte[] to java.security.Key? import java.security.Key; import javax开发者_开发百科.crypto.SecretKey;

How to get back from encoded byte[] to 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[]?

    }
}


Found! http://www.exampledepot.com/egs/javax.crypto/GetKeyBytes.html

Sorry for the inconvenience.

0

精彩评论

暂无评论...
验证码 换一张
取 消