SweatCoder
asked on
need encryption module
I have looked at quite a few posts in the VB section regarding modules for encryption that will work in VB. Many posts suggested home-baked encryption schemes, which I don't want to use. I'd like to tap into the Crypto-API that comes with windows, but all the vb examples i've found are in exe-format, and when i attempt to convert to dll format and make the functions useful for me, it breaks and i don't know why.
so i'm looking for a *simple* vb code sample with an encrypt function and a decrypt function, that utilizes the windows crypto api (or a better or more secure api if there's one obtainable for free out there).
Points will be awarded for a working sample that i don't have to modify. i just want to be able to specify my own seed value or key password, and the string i want to encrypt or decrypt.
"Is it secret? Is it safe?"
so i'm looking for a *simple* vb code sample with an encrypt function and a decrypt function, that utilizes the windows crypto api (or a better or more secure api if there's one obtainable for free out there).
Points will be awarded for a working sample that i don't have to modify. i just want to be able to specify my own seed value or key password, and the string i want to encrypt or decrypt.
"Is it secret? Is it safe?"
Maybe take a look at these from source forge :
http://sourceforge.net/projects/kiskis
This may or may not be of interest to you :
http://codecentral.borland.com/ccweb.exe/listing?id=23091
http://sourceforge.net/projects/kiskis
This may or may not be of interest to you :
http://codecentral.borland.com/ccweb.exe/listing?id=23091
I have found these as well :
http://www.rgagnon.com/pbdetails/pb-0170.html
http://www.codeguru.com/Cpp/COM-Tech/atl/atl/article.php/c3577/
http://feldstein.net/CodeCryptoArticle.htm
This site has some downloads and documentation :
http://www.slagellware.com/cryptoapi.downloads.html
http://www.rgagnon.com/pbdetails/pb-0170.html
http://www.codeguru.com/Cpp/COM-Tech/atl/atl/article.php/c3577/
http://feldstein.net/CodeCryptoArticle.htm
This site has some downloads and documentation :
http://www.slagellware.com/cryptoapi.downloads.html
ASKER
i have been to a lot of these sites already. the samples are bloated and confusing. they don't always work, etc. some require c++ compilation first. 500 points for whoever can give me simple encrypt/decrypt vb functions that taps into crypto api that ships with windows.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
fanpages, that is EXACTLY what I was looking for. . .unfortunately it doesn't compile. the VB6 debugger stops on this line:
Call Err.Raise(vbObjectError, strMODULE_NAME, "Error during CryptAcquireContext for a new key container." & _
It highlights "strMODULE_NAME" and says "compile error: variable not defined".
please help.
Call Err.Raise(vbObjectError, strMODULE_NAME, "Error during CryptAcquireContext for a new key container." & _
It highlights "strMODULE_NAME" and says "compile error: variable not defined".
please help.
Ooops... sorry.
I removed the definition to strMODULE_NAME before I posted the comment thinking it wasn't used, sorry.
It's just a constant that defines the name of the class where the code is stored.
e.g.
Private Const strMODULE_NAME As String = "clsCryptography"
You can replace strMODULE_NAME with any text you wish, e.g.
Call Err.Raise(vbObjectError, "My Class", "Error during CryptAcquireContext for a new key container." & _
Apologies again... I don't have VB installed on my machine... so didn't compile before sending.
BFN,
fp.
I removed the definition to strMODULE_NAME before I posted the comment thinking it wasn't used, sorry.
It's just a constant that defines the name of the class where the code is stored.
e.g.
Private Const strMODULE_NAME As String = "clsCryptography"
You can replace strMODULE_NAME with any text you wish, e.g.
Call Err.Raise(vbObjectError, "My Class", "Error during CryptAcquireContext for a new key container." & _
Apologies again... I don't have VB installed on my machine... so didn't compile before sending.
BFN,
fp.
ASKER
now this comes up undefined: lngERR_NUMBER_SUCCESS
please do me a favor and go through and define all vars/constants that need defining. i'm anxious to give you the points. . .but i need it to work.
this same thing has happened to me for every code sample i've downloaded and tried. undefined vars, etc., and when i try to resolve it myself i get in deeper and it never works.
so i await your reply. . .
please do me a favor and go through and define all vars/constants that need defining. i'm anxious to give you the points. . .but i need it to work.
this same thing has happened to me for every code sample i've downloaded and tried. undefined vars, etc., and when i try to resolve it myself i get in deeper and it never works.
so i await your reply. . .
ASKER
ok, so it was pretty obvious that lngERR_NUMBER_SUCCESS was a const to be set to 0, and now it WORKS (!). . .but I need the encrypted text to be in standard ascii chars (base64 encoded?). It currently contains nonprintable chars, etc. How can I do this?
THANKS. Almost there.
THANKS. Almost there.
ASKER
nevermind, i got it.
ASKER
even though it's working great from VB now, when I compile into a dll and call from asp, I get this error:
Error during CryptAcquireContext for a new key container. A container with this name probably already exists.
Please help. If you want me to post a new question, just let me know.
Error during CryptAcquireContext for a new key container. A container with this name probably already exists.
Please help. If you want me to post a new question, just let me know.
ASKER
I have posted a new question for the asp-related problem. Please come take a look:
https://www.experts-exchange.com/questions/21404315/advapi-encryption-breaks-in-asp.html
https://www.experts-exchange.com/questions/21404315/advapi-encryption-breaks-in-asp.html
http://www.pscode.com/vb/scripts/BrowseCategoryOrSearchResults.asp?txtCriteria=encryption&blnWorldDropDownUsed=TRUE&txtMaxNumberOfEntriesPerPage=10&blnResetAllVariables=TRUE&lngWId=1&optSort=Alphabetical