Code result different between "vscode" and "intellij idea"
See original GitHub issuehere is the code, about 3DES encryption
import java.security.Key;
import java.util.Base64;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
public class Main {
static String key = "693207DB8148FBC9D8410179";
static String iv = "20190225";
static String encoding = "gb2312";
static String data = "{\"parkCode\":\"1\",\"plateNo\":\"京A11113\"}";
public static String encrypt(String data) throws Exception {
DESedeKeySpec keySpec = new DESedeKeySpec(key.getBytes());
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("desede");
Key deskey = keyFactory.generateSecret(keySpec);
Cipher cipher = Cipher.getInstance("desede/CBC/PKCS5Padding");
IvParameterSpec ips = new IvParameterSpec(iv.getBytes());
cipher.init(Cipher.ENCRYPT_MODE, deskey, ips);
byte[] encryptData = cipher.doFinal(data.getBytes(encoding));
return Base64.getEncoder().encodeToString(encryptData);
}
public static void main(String[] args) throws Exception {
System.out.println(encrypt(data));
}
}
in vscode
, the result is
0edFaLw+X+9J2LHbzKQa0zo3RGmHII0JhagfRQLJhEVodBeA8XO6rw==
in intellij idea
, the result is :
0edFaLw+X+9J2LHbzKQa0zo3RGmHII0JXoSLu19d+/pvYydg1qZV5A==
I checked the class file, the Main.class in vscode
size is 2KB.
The Main.class size in 'intellij idea` is 3KB.
Here is the file: two classes.zip
Please check the problem, thank you for your time.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
IntelliJ IDEA vs. Visual Studio Code - G2
IntelliJ IDEA rates 4.6/5 stars with 2,002 reviews. By contrast, Visual Studio Code rates 4.7/5 stars with 1,915 reviews. Each product's score is...
Read more >How to see Visual Studio Code in comparison to JetBrains ...
IntelliJ is a full IDE which comes with 'everything' (intellisense, debugger etc) and VS Code is just a text editor. True, there are...
Read more >IntelliJ IDEA vs Microsoft Visual Studio Code | TrustRadius
Compare IntelliJ IDEA vs Microsoft Visual Studio Code. 1002 verified user reviews and ratings of features, pros, cons, pricing, support and more.
Read more >Visual Studio Code vs IntelliJ IDEA – Which is best for Java ...
The reasons are quite clear. Not only is VS Code (still) unsuitable for larger enterprise-level projects, it is also less reliable, responsive ......
Read more >Comparing Rust IDEs: IntelliJ IDEA, VS Code, and more
Let's look at seven of the best Rust IDEs and code editors, along with useful packages and plugins like IntelliJ Rust.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@15050050972 From the two compiled classes you attached you can see this; Intellij compiled class:
Vscode compiled class:
Note the “A” seems to be read incorrectly so I assume some kind of character encoding issue.
So I opened the files with a hex editor and converted them to UTF-8, the issue becomes clear. Using UTF-8, the vscode compiled file the plate number is
浜珹11113
whereas in intellij it is京A11113
. I do not believe this is an issue with vscode, on my end it has no trouble reading those characters.I found the reason
I need use
-encoding
option to specify the encoding of java file, otherwise javac will get default encoding from OS, my OS is windows, and I’m in China. So my default encoding isGBK