# \[JAVA\] AES security algorithm related - Why do I get different result values?

**URL:** https://discourse.processing.org/t/java-aes-security-algorithm-related-why-do-i-get-different-result-values/38947
**Category:** Coding Questions
**Created:** [September 23, 2022, 1:01pm UTC](https://discourse.processing.org/t/java-aes-security-algorithm-related-why-do-i-get-different-result-values/38947 "2022-09-23T13:01:58Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)
#### Post date: [September 23, 2022, 1:01pm UTC](https://discourse.processing.org/t/java-aes-security-algorithm-related-why-do-i-get-different-result-values/38947/1 "2022-09-23T13:01:58Z")

</div>

[JAVA] AES security algorithm related - Why do I get different result values?

hello.

I’m trying to test the AES256 algorithm.

* * *

[1. Type of test]

1. WEB SITE
2. JAVA Program

[2. Test information]

1. KEY : sdfhjiodfjisd231sdfhjiodfjisd231
2. TEXT : ShVmYq3t6w9y$B&E

* * *

[3. Actual test results]

1. site1: [https://aesencryption.net/](https://aesencryption.net/)  
256bit /  
output: USZet7l6QkYD/A9S5oIg+PbN/I7qRpWnkwqkKwWFS40=

2. site2: [An Online Tool for AES Encryption and Decryption](https://www.devglan.com/online-tools/aes-encryption-decryption)  
256bit/ECB  
output: Fe+8zzw4vSJJ5qxdGWZSJkTEEBrlb7/NK4Kdt+y+2IQ=

3. JAVA: [Java AES Encryption Decryption Example - HowToDoInJava](https://howtodoinjava.com/java/java-security/java-aes-encryption-example/)  
256bit/ECB  
output: IcApWVcdC2qIB58LDtrMaEG95F6Yt7uBmpdhUrx5XuE=

4. JAVA: [Java AES-256 Encryption and Decryption Examples](https://howtodoinjava.com/java/java-security/aes-256-encryption-decryption/)  
256bit/ECB  
output : K5tWglkjfdF4MZPLfPfxbV/mNt9Ugd+2wWS3SMZCH98=

 ![fig](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/3/b3a1172cea5b3d50a27b63901ef6b9eacdc86843.jpeg)

```auto
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Base64;

private static String secretKey = "sdfhjiodfjisd231sdfhjiodfjisd231"; 
String originalString = "ShVmYq3t6w9y$B&E";

void setup(){
    size(500, 500);
    println("-------------------------------");
    println(originalString);
    String encryptedString = AES.encrypt(originalString, secretKey); 
    String decryptedString = AES.decrypt(encryptedString, secretKey);
    println(encryptedString);
    println(decryptedString);
    
    println("-------------------------------");
    String encryptedString2 = AES256.encrypt(originalString);
    String decryptedString2 = AES256.decrypt(encryptedString2);
    System.out.println(originalString);
    System.out.println(encryptedString2);
    System.out.println(decryptedString2);
    println("-------------------------------");    
}

```

I don’t know why the results are different.  
Anyone know? help me.
