This is a question about changing the seed encryption value of Java to C language.

Asked 2 years ago, Updated 2 years ago, 36 views

If the value is exceeded by an encrypted value (using seed128 cbckisa open source) on the web, we will try to decrypt it with c.

Java Side

private static byte pbUserKey[]  = StringUtil.StringToByteLength("indexUserKey", 16); 
private static byte bszIV[]  = StringUtil.StringToByteLength("indexVectorKey", 16); 
private static String seed_utf = "utf-8";
byte[] enc_nt = null;
String str;
enc_nt = SEED_CBC_Encrypt(pbUserKey, bszIV, str.getBytes(seed_utf ), 0, str.getBytes(seed_utf ).length);
byte[] dec_nt = null;
dec = SEED_CBC_Decrypt(pbUserKey, bszIV, enc_nt , 0, enc_nt .length);

How should I receive it from page c?

private static byte pbUserKey[]  = StringUtil.StringToByteLength("indexUserKey", 16); 
//--> BYTE pbUserKey[] = I wonder how to get the top back.
enc_nt = SEED_CBC_Encrypt(pbUserKey, bszIV, str.getBytes(seed_utf), 0, str.getBytes(seed_utf).length);

How should str.getBytes(seed_utf) be received from c above? And .Also length.

I did it like below, but it didn't work.

 enc_nt = SEED_CBC_Encrypt(pbszUserKey, pbszIV, seed_utf , 0, strlen(seed_utf ));
 dec_nt = SEED_CBC_Decrypt(pbUserKey, bszIV, enc_nt , 0, strlen(enc_nt ));

Please answer me.

c++ c

2022-09-22 10:38

1 Answers

Java uses Unicode (utf16be).

In other words, wcslen should be used instead of the ansi tolerance strlen.

If it's communication between Java and c, you have to pay attention to encoding.

Java has fewer side effects due to os, but c should also pay attention to os settings.

GetBytes is literally converting to an array of bytes for encryption/decryption.

Length is to find the length of the array.

Receive an encrypted string from c and test it first

If there is no problem with encryption/decryption tests in c, consider sending data between Java <-> c.


2022-09-22 10:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.