invalid AES key length error

前端 未结 4 1343

this code give invalid AES key length error. how can i correct it ? ( i want 128 bit key AES encryption )

package org.temp2.cod1;
import java.security.*;

im         


        
4条回答
  •  感情败类
    2020-12-08 08:15

    You can get this error when the key you're trying to use isn't the right length.

    So in psuedocode, you're trying something like this:

    String key = "123";
    SecretKeySpec k =  new SecretKeySpec(key, "AES");
    

    but the key is too short - it needs to be something like, say 31 characters long.

    So check your key value -> it's probably stored somewhere incorrectly.

提交回复
热议问题