is AES key random?

后端 未结 4 1351
轮回少年
轮回少年 2021-02-10 22:46

AES key may be generate by this code

KeyGenerator kgen = KeyGenerator.getInstance(\"AES\");
kgen.init(128); 

but

If I have a \"very re

4条回答
  •  灰色年华
    2021-02-10 22:57

    You can add a random algorithm using SecureRandom :

        KeyGenerator keyGen = KeyGenerator.getInstance("AES");
        SecureRandom random = new SecureRandom(); // cryptograph. secure random 
        keyGen.init(random); 
        SecretKey secretKey = keyGen.generateKey();
    

提交回复
热议问题