Hi Rajesh,
in short there's so much wrong in your parameterization that it doesn't work.
There are lots of sets of test vectors to see, whether an encryption library gets the expected results from the algorithm used. The download of vfpencryption comes with source examples. Look into the directory "test-vectors". Go from there
------------------------------
If you're interested to see what's all wrong with your try:
What you want ([tt]biXhp3Ha1fgxVEp48zHrvVoXMStmxPuAPHo3TVz5lHU=[/tt]) is base64, which is not hex or hexadecimal.
What you have as result of Encrypt ([tt]O4¨n)Ks³â÷„[/tt] ) is binary. You get from binary to base64 with STRCONV(), see the help. But don't try just using STRCONV() on the result, as there are lots of further errors.
Maybe because you have that misconception you're also feeding in a wrong lcKey and overall a lot of wrong parameter values.
The Encrypt function of the VfpEncryption library asks for a specific key length when you use it for AES:
Read what the documentation says:
docs said:
keys may need to be of a particular length for certain types of encryption
docs said:
2 = Rijndael\AES 256 (requires a 32 character Key) *Default
There are some of your parameterization errors:
1. Your parameterization says you want to use AES 256 but a 24 character key. The algorithm determines the key length. And for AES356 you need a 32 character (32 bytes) key.
Your lcKey='BeY7nZ1HL5Sdl0POADQACw==' is 24 chars, and the characters used and the trailing with "==" tells me this is base64. And if you convert that back to a binary string, not only limited to letters and digits, this would become even shorter, a 16 byte key.
2. Your description is you want to encrypt a key. Well, to the Encrypt function it doesn't matter that lcStr='mykey1232456' is your key, to the AES256 encryption that is the message to encrypt and the key used to encrypt this message is lcKey and that's too short no matter if you take it as is or convert it back to a 16byte long binary key.
3. Your parameterization is mode 1 for CBC, your comment says you want ECB, but ECB is mode 0, not mode 1.
So just read the documentation and follow it correctly.
Encryption isn't a beginner topic if you still even struggle with understanding what binary, hexadecimal, bas64 are and then make it hard to wrap your head around what you need to provide as parameters by wanting to encrypt a key, which makes it easy to confuse message and key, it's just natural your first trials lead to errors.
You can also blame Craig S. Boyd for having a parameterization that suggests more freedom than you really have. You can't mix AES type and key length as you like, so actually only using encryption types 4 (Blowfish) and 1024 for RC4 would enable more freedom of choices in key lengths, the other modes determine what has to be the key length and so the nKeySize parameter has to be that and not what you want.
Bye, Olaf.
Olaf Doschke Software Engineering