|
Hi all,
I am new to encrypt and decrypt.
I want to encrypt/decrypt a fixed length small block of data. It is there any sample methord that don't need key?
Thanks
laura
|
|
|
|
|
add 128 to each byte. that's about as secure as you can get, without using a key of some kind.
-c
A | B - it's not a choice.
|
|
|
|
|
Chris Losinger wrote:
add 128 to each byte. that's about as secure as you can get, without using a key of some kind
But wouldn't 128 be a sort of a key too?
--
karl
|
|
|
|
|
Would someone help me by telling me why this doesnt work? I'm trying to write an easy way for me and my co-admins to change users passwords w/o using the standard tools. Note, that the DC= parts reflect my current Active Directory DC on my test machine. I know for a fact that the user I am requesting is at CN=UserName,CN=Users,DC=HOME,DC=Local.
void CChangePWDDlg::OnChangepw()
{
CString sUID, sPassword, sPWConfirm;
GetDlgItemText(IDC_USERID, sUID);
GetDlgItemText(IDC_PASSWORD, sPassword);
GetDlgItemText(IDC_PWCONFIRM, sPWConfirm);
if (sUID.GetLength() == 0)
{
AfxMessageBox("User ID cannot be empty");
return;
}
if (sPassword.GetLength() == 0)
{
AfxMessageBox("Password cannot be empty");
return;
}
if (sPWConfirm.GetLength() == 0)
{
AfxMessageBox("Re-Enter Password");
return;
}
if (strcmp(sPassword, sPWConfirm) != 0)
AfxMessageBox("Passwords Don't Match");
else
{
CString objPath = "LDAP://CN=";
objPath = objPath += sUID;
objPath = objPath += ",CN=Users,DC=HOME,DC=Local";
BSTR oPath = objPath.AllocSysString();
IADsUser *pUser;
HRESULT h2;
h2 = ADsGetObject(oPath, IID_IADsUser, (void**) &pUser);
if (FAILED(h2))
{
AfxMessageBox("Failed to get user");
SysFreeString(oPath);
pUser->Release();
return;
}
else
{
SysFreeString(oPath);
BSTR oPass = sPassword.AllocSysString();
HRESULT hr;
hr = pUser->SetPassword(oPass);
pUser->Release();
if (FAILED(hr))
{
AfxMessageBox("Failed to set password");
return;
}
else
{
SetDlgItemText(IDC_USERID, "");
SetDlgItemText(IDC_PASSWORD, "");
SetDlgItemText(IDC_PWCONFIRM, "");
}
}
}
}
I always receive "Failed to get user".
Thanks,
Frank
PS. Alot of this code was used from examples on MSDN.
|
|
|
|
|
Hello guru's around the world!
I'm writing some software to handle some simple home-made hardware under windows2000.
I need to use 2 input and 2 output channels, being: DSR, CTS, RTS, DTR. I open the serial port using CreateFile(..) , non overlapped. Toggleing the output channels with EscapeCommFunction(..) works fine too.
A worker tread is in an infinite loop (while(true)) in which it waits for a WaitCommEvent(..) . When the DSR or the CTS lines change state, I get notified - just as it should be.
But I want to keep polling with WaitCommEvent(..) and I want to use EscapeCommFunction(..) to toggle the output lines.
To be more exact, I need to be able to give pulses to the DTR and watch what happens to the CTS (input). Unfortunatly, EscapeCommFunction(..) hangs if WaitCommEvent(..) is still waiting for an event.
Do I NEED to use overlapped IO for this? Or is it possible to change the DTR status while polling the CTS?
Thanks in advance,
Regards,
Griffith Sutherns
Everything you say will be misquoted, ripped out of context and used against you.
|
|
|
|
|
In non-overlapped IO each call will block the IO resource.
You will also run into problems when you try to exit from your thread because it will be stuck on WaitCommEvent.
You have a couple of choices:
1. Don't use WaitCommEvent and instead poll the IO with GetCommModemStatus.
Polling can be OK if done infrequently.
2. Use overlapped IO. A little more complicated but it won't block the IO resource.
I'd go with overlapped IO.
Col
|
|
|
|
|
Thanks a lot Colin!
I'll look into GetCommModemStatus first, that might just be what I was looking for. Although I do need need to poll about 80 times in a few seconds, it might still work reliably.
Once again, your help's greatly appriciated.
Regards,
Griffith
Everything you say will be misquoted, ripped out of context and used against you.
|
|
|
|
|
BTW,
Since you plan to poll you should do it at least double the maximum possible expected input frequency to ensure you do not miss a pulse.
Col
|
|
|
|
|
I use visual studio.net enterprise architect
I'm coding an app with MFC.
I have a problem. After including some source directory (containing *.inl) into the include path of the project properties, VS.net crash when I use project -> 'add ressource'.
Any Ideas?
Everything's beautiful if you look at it long enough...
|
|
|
|
|
why this routine stops everytime with the errorMessageBox??
thx for help.
m_Path: absolute path to the file (for example "c:\data\test.log"
void CTestDlg::OnOK()
{
this->UpdateData(true);
CString error;
CStdioFile logFile;
CFileException fileException;
if (!logFile.Open( m_Path, CFile::modeRead ),
&fileException )
{ //ERROR
error.Format( "Can't open file %s, error = %u\n",
m_Path, fileException.m_cause );
MessageBox(error,NULL,MB_OK);
}
else
{ //all okay
logFile.Close();
}
CDialog::OnOK();
}
|
|
|
|
|
what does fileException.m_cause contain?
-c
A | B - it's not a choice.
|
|
|
|
|
the errorcode...
but i think i found the problem...
its strange... 1 day searching without success
and some minutes after this post i found a wrong placed ")"
in the if-cause ...
the ")" should be after the exception-var...
|
|
|
|
|
Hello,
I have some really simple wininet code that performs and http post and closes the handles when done. I am having a problem where on app exit, I perform a final http post and close all of my handles without fail and exit my wininet function, but the app refuses to unload until after a 60 second pause. Any ideas why?
|
|
|
|
|
Is there a simple way inside the VS6 IDE to automatically change the color of code between a #if ... #endif, preferable when using #if 0 ... #endif, which effectively removes an entire section of code? Since comments between /* ... */ can be colored, can't this be done with #if too?
Thanks,
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
For this situation, you must use macro. Writing a macro to do what you want!
A. Riazi
|
|
|
|
|
Nope, there's no way to do it.
I personally avoid leaving portions of commented-out code in my source files, whether it's with /*...*/ or #if 0. If something needs to be removed, I delete it, and I rely on my version control software to let me recover it later if necessary. I just hate looking at code with old junk all over it.
Regards,
Alvaro
All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
|
|
|
|
|
You might want to look at Visual Assist, from Whole Tomato Software
www.wholetomato.com[^]
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
I am about to write code that will perform a dynamic_cast from Base* to Derived* in a function that got the Base* from a 'this' in a constructor.
Example :
<br />
class Base;<br />
void do_stuff( Base* );<br />
<br />
class Base<br />
{<br />
public:<br />
Base( );<br />
};<br />
<br />
class Derived : public Base<br />
{<br />
public:<br />
Derived( )<br />
{<br />
do_stuff( this );<br />
}<br />
};<br />
<br />
void do_stuff( Base* pBase )<br />
{<br />
Derived* pDerived = dynamic_cast< Derived* >( pBase );<br />
if( pDerived )<br />
do_more_stuff( pDerived );<br />
}<br />
I know using an object's virtual functions within its constructor is bad, because the virtual function table is not completely built yet. I have read about dynamic_cast stating that it can convert complete objects to complete objects, is that related to the vtable?
So, can I dynamic_cast<> a 'this' in a constructor?
----------------
Blaster
Computer game programmer and part time human being
http://www.blastersoft.com
|
|
|
|
|
Sounds like a design problem.
"But that's just my opinion... I could be wrong."
-pete
"No matter where you go, there your are..." - Buckaoo Banzi
<pete>
|
|
|
|
|
You do not need cast here, or static_cast at most. As for hypothetical bad idea of using partially constructed objects in the cast - it might not work with diamond inheritance, at least not the way intended.
|
|
|
|
|
Ufff, you're entering into quicksands here... Anyway, I think your code should work. The standard says (12.7):
5 Dynamic_casts (_expr.dynamic.cast_) can be used during construction or
destruction (_class.base.init_). When a dynamic_cast is used in a con-
structor (including from the mem-initializer for a data member) or in
a destructor, or used in a function called (directly or indirectly)
from a constructor or destructor, if the operand of the dynamic_cast
refers to the object under construction or destruction, this object is
considered to be a most derived object that has the type of the con-
structor or destructor's class. If the operand of the dynamic_cast
refers to the object under construction or destruction and the static
type of the operand is not a pointer to or object of the constructor
or destructor's own class or one of its bases, the dynamic_cast
results in undefined behavior. If you read carefully, when entering into the ctor for Derived the object already behaves as a Derived with respect to dynamic_cast .
Besides, if you're writing such a mess just to avoid calling a virtual function, then you better move to virtual because similar rules apply (and the code is a little more understandable).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I may or may not work, but I no longer care.
Like someone said, the design is bad. I changed things a bit.
Thank you all for you information.
----------------
Blaster
Computer game programmer and part time human being
http://www.blastersoft.com
|
|
|
|
|
Damn! I just realised that in my example, the call to "do_stuff" should have been in Base's constructor, not in Derived's.
I still don't care though.
----------------
Blaster
Computer game programmer and part time human being
http://www.blastersoft.com
|
|
|
|
|
At this time I have a window in which i draws and saves screen window as bmp.
But i want to draw shapes on a window that is hidden.
I am confused that with which device context i should draw.
It will be great if u guide me on this problem.
|
|
|
|
|
dont use a window device context as such
create a memdc compatible with the window dc bitmap and draw there
"even if my world is weird its my world" biz stuff about me
|
|
|
|