0

I want to know why the first result is different from the second one?

full code:

public static void main throws Exception
{
        KeyGenerator kg = KeyGenerator.getInstance("RC2");
        SecretKey sk = kg.generateKey();
        byte[] key = sk.getEncoded();

        System.out.println(Arrays.toString(key));
        System.out.println("****");
        SecretKey sk1 = new SecretKeySpec(key, kg.getAlgorithm());

        boolean status = sk1.equals(sk);  
        System.out.println(status); //the result is true
        System.out.println(sk1==sk); //the result is false
}
Brock Adams
  • 86,878
  • 22
  • 220
  • 282

0 Answers0