|
can any one send me code for encryption/decryption string using DES.
|
|
|
|
|
It's not DES, but it uses the Windows-CryptAPI.
On the other hand I'm quite sure there is a class outside in the wild which provides DES-encryption.
<br />
HCRYPTPROV hCryptProv;<br />
HCRYPTKEY hKey;<br />
HCRYPTHASH hHash;<br />
<br />
if ( !CryptAcquireContext(&hCryptProv, NULL , NULL, PROV_RSA_FULL, 0))<br />
AfxMessageBox("Error Acquire");<br />
<br />
if ( !CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash))<br />
AfxMessageBox("Error CreateHash");<br />
<br />
if ( !CryptHashData(hHash, (BYTE*) "YourKey", (DWORD)strlen("YourKey"), 0))<br />
AfxMessageBox("Error Hashing");<br />
<br />
if ( !CryptDeriveKey(hCryptProv, CALG_RC4, hHash, 0, &hKey))<br />
AfxMessageBox("Error Derive Key");<br />
<br />
BYTE* buf;
DWORD size = (DWORD)strlen((char*)buf);<br />
<br />
CryptEncrypt(hKey, NULL, TRUE, 0, (BYTE*)buf, &size, size);<br />
<br />
CryptDecrypt(hKey, NULL, TRUE, 0, (BYTE*)buf, &size)<br />
<br />
This works fine for me. It's not a high-security app, so i hardcoded the encryption-key in the code. I simply took the Class-Name as key.
Hope I could help.
--
karl
|
|
|
|
|
i need simple DES encryption / decryption with hardcoded key. Thanks a lot Karl i will try this.
|
|
|
|
|
Thanks a lot Mr.Karl, it worked but now i have data which contanis 300 character but it encrypts forst 56 characters only. can u please tell me how can i do this both encryption and decryption.
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/Security/cryptencrypt.asp
--
karl
|
|
|
|
|
thanks karl,
i have 2 questions.
1. i implemented that code it encrypts first 56 characters 8 in each cryptencrypt call on next call it founds "space character" as first character in block it can not encrypt it,next blocks are encrypted but not added to result just because of "Space character".
How can i resolve this problem.
and my next question is that i am writing this code to be a platform independent can i implement same encryption/decryption in jave,
i will encrypt text in VC and Decrypt it in Java and vice versa.
can u please send me some sample code for block cipher and stream cipher.
if i nned to use some other algorithm than can u please send some sample.
Zaid
|
|
|
|
|
If I have a double type field in a jet database and the value 8.95 stored in it then when I retrieve it from the database as a string representaion it gives me "8.9499999999999993"
Is this just because the double type cannot represent the value 8.95 exactly? I have noticed that not all values come back as a huge string, e.g. 10.99, 1.95, and 8.5 are all exactly as entered. Or is it a bug with the code in the database driver that is doing the conversion?
|
|
|
|
|
|
Does anyone know the technique to allow a background bitmap to be displayed for a CProgessCtrl.
Specifically what functions to override and implement. I think it is not possible to use DrawItem unless you make CProgressCtrl to be Owner Drawn.
Many Thanks In Advance
|
|
|
|
|
Hi,
I dont know can implement this technique or not? But this is an idea:
1- Create a PictureBox control to show your bitmap
2- Use SetParent API function to change parent of PictureBox control.
3- Set your ProgressBar control as parent of bitmap PictureBox.
A. Riazi
|
|
|
|
|
i have KaZZA and i was wondering if it's legal if i download a version of Visual C++ 6.0, if i did would i be able to register it without WINDOWS coming and knocking on my door telling me to give it up, lol
|
|
|
|
|
Behold, this years winner in the 'stupidest man of the year contest'.
Yeah, it's legal, just send your details to piracy@microsoft.com and they will fix you up.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
I am attempting to programmatically create a copy of a shortcut using the IShelllink interface. When I interogate most *.lnk files, the GetPath function returns a true target ie. "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe". There are some special shortcuts however, that behave differently. For example, a shortcut to MS Word returns the
C:\windows\installer\{ some guid }\wordicon.exe. from the GetPath function.
How can I determine the true target (ie: winword.exe ) given the information from the IShelllink functions?
Any suggestions?
|
|
|
|
|
from http://www.codeproject.com/editctrl/dropedit.asp[^]
CString ExpandShortcut(CString &inFile)
{
CString outFile = "";
ASSERT(inFile != _T(""));
IShellLink* psl;
HRESULT hres;
LPTSTR lpsz = inFile.GetBuffer(MAX_PATH);
hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID*) &psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*) &ppf);
if (SUCCEEDED(hres))
{
WORD wsz[MAX_PATH];
::MultiByteToWideChar(CP_ACP, 0, lpsz, -1, wsz, MAX_PATH);
hres = ppf->Load(wsz, STGM_READ);
if (SUCCEEDED(hres)) {
WIN32_FIND_DATA wfd;
HRESULT hres = psl->GetPath(outFile.GetBuffer(MAX_PATH),
MAX_PATH,
&wfd,
SLGP_UNCPRIORITY);
outFile.ReleaseBuffer();
}
ppf->Release();
}
psl->Release();
}
inFile.ReleaseBuffer();
return outFile;
}
A | B - it's not a choice.
|
|
|
|
|
We actually do just what is described above. We are interogating the Microsoft Word.lnk file ( the shortcut installed in the Documents and Settings\AllUsers.Windows\StartMenu\Programs\Office\Microsoft Word.lnk). The problem is, the IShellLink->GetPath function returns C:\windows\installer\{ GUID }\wordicon.exe . But we all know that when a user runs Microsoft Word, the process running is called winword.exe. How does the system launch winword.exe when the shortcut target is wordicon.exe ?
|
|
|
|
|
We actually do just what is described above. We are interogating the Microsoft Word.lnk file ( the shortcut installed in the Documents and Settings\AllUsers.Windows\StartMenu\Programs\Office\Microsoft Word.lnk). The problem is, the IShellLink->GetPath function returns C:\windows\installer\{ GUID }\wordicon.exe . But we all know that when a user runs Microsoft Word, the process running is called winword.exe. How does the system launch winword.exe when the shortcut target is wordicon.exe ?
|
|
|
|
|
hi,
how do you make the header, in report mode(list control), not clickable?
thx in advance!
|
|
|
|
|
Add the LVS_NOSORTHEADER style to the list.
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
What is the best and/or the most reliable method of testing of a LAN is connected to the Internet.
The Wininet APIs make it easy to tell if the user is connected to a dialup modem, and a LAN, but there is no direct way to tell if the LAN is connected to the Internet.
Sending an IMCP packet is not a possibility, other than that I am open to your suggestions.
Thanks
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Paul Watt wrote:
What is the best and/or the most reliable method of testing of a LAN is connected to the Internet.
To try to connect to a (few) known high-uptime site(s)?
|
|
|
|
|
I want to give color red for status = "Late", and blue for status = "Assigned" for each row in a list control. I tried ON_NOTIFY as suggested by many programmers found from www.google.com. But I can't get it to work. Here is the ON_NOTIFY function:
BOOL CProjectSearchView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
NMHDR *p = (NMHDR*) lParam;
//take the default processing unless we set this to something else
if (p->code == NM_CUSTOMDRAW)
{
if (m_pSet->m_STATUS == "LATE")
{
*pResult = CDRF_DODEFAULT;
NMLVCUSTOMDRAW* lvcd = (NMLVCUSTOMDRAW*)p;
if (CDDS_PREPAINT == lvcd->nmcd.dwDrawStage)
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if (CDDS_ITEMPREPAINT == lvcd->nmcd.dwDrawStage)
{
//this is the prepaint stage for an item
COLORREF crText;
crText = RGB(255, 0, 0);
//store the color back in the NMLVCUSTOMDRAW struct
lvcd->clrText = crText;
//tell windows to paint the control itself
*pResult = CDRF_DODEFAULT;
}
}
}
return CRecordView::OnNotify(wParam, lParam, pResult);
}
-Elizabeth
Eilzabeth
|
|
|
|
|
Don't call the base class OnNotify() , it's wiping out the return value you store in pResult .
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I got it working now. I created a custom draw handler by following the tutorial in http://home.inreach.com/mdunn/code/LVCustomDraw/LVCustomDraw.html.
Handler
ON_NOTIFY(NM_CUSTOMDRAW, IDC_PROJECT_LIST, OnCustomdrawProjectList)
Prototype
afx_msg void OnCustomdrawProjectList(NMHDR* pNMHDR, LRESULT* pResult);
-Elizabeth
Eilzabeth
|
|
|
|
|
hi,
when i create a message box using afxmessagebox, can i get afxmessagebox to display the input string(the 1st parameter) in different font, size and color?
thx in advance!
|
|
|
|
|
Check out ClsMessageBox , part of Jan van den Baard's ClassLib[^].
---
Shog9
I see the way the salesmen stare into the sun
I stood and watched them as they fell off one by one...
|
|
|
|