see if this example helps
http://snipplr.com/view/16
Main Topics
Browse All TopicsRelated Question Here: http://www.experts-exchang
I have finished with Java and C++ encryption using ECB, one of the more simple encryptions of AES.
However, CBC and CFB require a IvParameterSpec/Chain to function properly.
I am not sure how to go about this, for C++, I've done, when making the key:
oRijndael.MakeKey("abcdefg
sm_chain0 being a simple: \0\0\0\0\0\0\0\0\0\0\0\0\0
C++ sample:"
CRijndael oRijndael;
oRijndael.MakeKey("abcdefg
char szDataIn_Orig[] = "aaaaaaaaaaaaaaaa";
//Test ECB
int nLen = strlen(szDataIn_Orig);
char *szDataIn = new char[nLen + 1];
memset((char *)szDataIn, 0, nLen + 1);
strcpy(szDataIn, szDataIn_Orig);
// To encrypt
char szDataOut[17] ="\0\0\0\0\0\0\0\0\0\0\0\0
oRijndael.ResetChain();
oRijndael.Encrypt(szDataIn
std::string encoded = base64_encode(reinterpret_
"
java sample:
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.*;
import java.io.*;
import java.util.prefs.*;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
class test2 {
public static void main(String[] args) throws Exception {
String plaintext = "abcdefghabcdefgh";
String key = "abcdefghabcdefgh";
byte iv[16];
for (int i =0;i<iv.length;i++)
{
iv[i]=0;
}
IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
SecretKeySpec keyspec = new SecretKeySpec(key.getBytes
Cipher cipher = Cipher.getInstance("AES/CF
cipher.init(Cipher.ENCRYPT
byte[] encrypted = cipher.doFinal(plaintext.g
String st = new String(encrypted);
System.out.println("Osterm
BASE64Encoder base64 = new BASE64Encoder();
String encodedString = base64.encodeBuffer(encryp
System.out.println("Osterm
}
}
Would be example coding for the encoded. Using CRijndael::ECB for C++ and AES/ECB/NoPadding for java works great. However, swappingt o CFB or CBC that eneds the IV key does not work well.
Any suggestions on how I can get the 'keys' synced up? I am maybe thinking the java side key isn't working properly, as I'm not to well (just started a couple days ago) with java.
The general attached files like before are still at http://stellarfrontier.net
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
see if this example helps
http://snipplr.com/view/16
Hey there, I actually got a similar example but I'm not sure how IV works.
I mean, I have it working java side too, but again like the last question, they aren't matching up with CFB. However, the IV is something that has to be similar i'm guessing too, much like the key.
private static byte[] iv = new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6,
0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF };
Though I see that, which I guss would be
0123456789ABCDEF (Caps)as the IV.
And for C++ side, I thought while using the key oRijndael.MakeKey("abcdefg
But apparently is different.
But I think the C++ 'chain' as they say and the IV are 'similar', or so I think.
Business Accounts
Answer for Membership
by: VallerianiPosted on 2009-08-12 at 03:24:31ID: 25077245
Oh ignore the comment of //test ECB. I still haven't changed much from the last coding for comments and junk. Just been trying to get it to work first!