Ich benötige einfachen Kennwort Script, Hilfe??
-
Hallo, benötige ich einen einfachen Script, der den Benutzer für ein Kennwort auffordert, nach dem Eintragen meiner Anwendung. wenn das rechte Kennwort vom Benutzer eingegeben wird, dann würde einfacher Bestätigung Schirm dann genrated, I'm mit Visual Studio C++, Danke
-
Hallo,
Ich wuerde ja schon fast sagen, da hat google-Translation mal wieder versagt.
Kannst auch auf Englisch posten.
Oder du solltest dir einfach deinen Satzbau nochmal anschauen
mfg
v RPS: Hab meinen Babel-Fisch verloren, kann mir den jemand wiederbringen? Braeuchte
den in letzter Zeit immer oefter hier, meinen Reiseleiter koennte mir auch grad
jemand wieder vorbeibringen. Aber nicht das Handtuch vergessen.
-
sorry for my first tranlation, I used bable fish and it tranlated back fine, so I thought it would be good, anyway..
basically what I was trying to say is, that I need a simple password protect script that protects my program, and when a user trys to use it they are faced with a login form upon load of the prog. Then, if they enter the correct password, a confirmation screen will appear.. it just needs to be real simple, I am using visual studio c++ BTW, thanks
Bable Fish: http://world.altavista.com/
-
3mu180r schrieb:
sorry for my first tranlation, I used bable fish and it tranlated back fine, so I thought it would be good, anyway..
*g* I thought something like this
basically what I was trying to say is, that I need a simple password protect script that protects my program, and when a user trys to use it they are faced with a login form upon load of the prog. Then, if they enter the correct password, a confirmation screen will appear.. it just needs to be real simple, I am using visual studio c++ BTW, thanks
I guess you program with MFC? If so, you better post your question in the
"MFC with Visual C++"-forum.But when you just looking for some code, here a little example:
//somewhere in your program const char *passwd = "my_password"; string password; //user input //...handle events for user-input or something else... //button-click-event or something like this if(password == passwd) //login granded else //login denied
because in this example the password 'my_password' is writen in cleartext,
someone could get the password by using a hex-editor. so maybe you will
encrypt the password in hexa-dezimal-form. its just a simple solution but
at this way you can't find the password in cleartext in the file. of course
you can encrypt the password in other ways.mfg
v R
-
thank you for that example, couple questions though:
first here is my \1:
// new.cpp : Defines the entry point for the console application. // const char *passwd = "my_password"; string password; //...handle events for user-input -- ?? //button-click-event -- ?? if(password != passwd) { printf("Wrong"); } else { printf("Correct"); }
I placed ?? where I have no idea of what to do.. I attempted to type something logical to show you what I'm trying to do.. this simple program will be purely for my own education, and will be a great example to learn from, if someone could add to it for me, I would be very grateful.. thanks in advance
-
I thought that you using the mfc or winapi and that you made a gui. But in this
case i misunderstood something, sry.Because you write a console program you can just ignore and delete the comments
i made related to some events.A simple program with user login:
bool checkPasswd(std::string &password) { if(password == passwd) return true; return false; } int main() { std::cout<<"first login to get the result of 1 + 1 ;): "; std::string userPasswd; std::cin >> userPasswd; if(checkPasswd(userPasswd)) std::cout<<"\n"<<1 + 1<<"\n"; else std::cout<<"\nAccess Denied!\n"; return 0; }
Of course this program is just an example.
I guess this example should makes it clear
mfg
v R
-
@vR: Du übersetzt aber auch mit Google was
MfG SideWinder
-
@vR: maybe you can tell us also something about the definition of 'passwd'
-
man I keep trying to compile this but it keeps saying:
fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.#include "cdosysstr.h" bool checkPasswd(std::string &password) { if(password == passwd) return true; return false; } int main() { std::cout<<"first login to get the result of 1 + 1 ;): "; std::string userPasswd; std::cin >> userPasswd; if(checkPasswd(userPasswd)) std::cout<<"\n"<<1 + 1<<"\n"; else std::cout<<"\nAccess Denied!\n"; return 0; }
any ideas why?? thanks
-
#include <iostream>
#include <string>Best regards,
SideWinder
-
And try:
std::getline(std::cin,userPasswd);
instead of:
std::cin >> userPasswd;
Best regards,
SideWinder
-
...too late
but still: where is the definition of 'passwd'? in cdosysstr.h??
-
I am horrible at this, I made the changes you suggested and it is still giving me the same error, he makes a good point, I haven't any idea how to define the header.. this will be my first attempt at C++ programming, so sorry for all the lame questions, however I know if I can get this working I will learn alot from it.. so, help is much appreciated..
here's my current attempt:
// kok.cpp : Defines the entry point for the console application. // #include <iostream> #include <string> bool checkPasswd(std::string &password) { if(password == passwd) return true; return false; } int main() { std::cout<<"first login to get the result of 1 + 1 ;): "; std::string userPasswd; std::getline(std::cin,userPasswd); if(checkPasswd(userPasswd)) std::cout<<"\n"<<1 + 1<<"\n"; else std::cout<<"\nAccess Denied!\n"; return 0; }
thanks
-
Would be nice if you post the compile-error-messages!
freshman is right, the string "passwd" isn't defined. Just add this at the beginning from the checkPasswd() function:
std::string passwd = "secret";
Best regards,
SideWinder
-
is this what you meant for me to do:
// kok.cpp : Defines the entry point for the console application. // #include <iostream> #include <string> bool checkPasswd(std::string passwd = "secret"; &password) { if(password == passwd) return true; return false; } int main() { std::cout<<"first login to get the result of 1 + 1 ;): "; std::string userPasswd; std::getline(std::cin,userPasswd); if(checkPasswd(userPasswd)) std::cout<<"\n"<<1 + 1<<"\n"; else std::cout<<"\nAccess Denied!\n"; return 0; }
this isn't working either.. here is my errors:
--------------------Configuration: kok - Win32 Debug--------------------
Compiling...
kok.cpp
C:\Documents and Settings\CodeOne\Desktop\vcZipPw\kok\kok.cpp(6) : error C2143: syntax error : missing ')' before ';'
C:\Documents and Settings\CodeOne\Desktop\vcZipPw\kok\kok.cpp(6) : error C2059: syntax error : ')'
C:\Documents and Settings\CodeOne\Desktop\vcZipPw\kok\kok.cpp(6) : error C2501: 'password' : missing storage-class or type specifiers
C:\Documents and Settings\CodeOne\Desktop\vcZipPw\kok\kok.cpp(6) : error C2239: unexpected token '{' following declaration of 'password'
Error executing cl.exe.kok.obj - 4 error(s), 0 warning(s)
thank you
-
where's the problem?
#include<iostream> #include<string> bool checkPasswd(std::string &password) { std::string passwd = "secret"; if(password == passwd) return true; return false; } int main() { std::cout<<"first login to get the result of 1 + 1 ;): "; std::string userPasswd; std::getline(std::cin,userPasswd); if(checkPasswd(userPasswd)) std::cout<<"\n"<<1 + 1<<"\n"; else std::cout<<"\nAccess Denied!\n"; return 0; }
Compiling...
forumHP.cpp
forumHP.obj - 0 error(s), 0 warning(s)
-
-
thank you very much, I will certainly learn alot from refrencing this script, you guys are awesome, thanks again
-
SideWinder schrieb:
@vR: Du übersetzt aber auch mit Google was
MfG SideWinder
Ne, aber du kannst um diese Uhrzeit nicht von mir erwarten, dass ich schon
gutes Englisch schreibe :D.Oder wuerdest du sagen, dass google es _noch_so_gut_ hinbekommen haette?
mfg
v R
-
freshman schrieb:
@vR: maybe you can tell us also something about the definition of 'passwd'
Die hatte ich in meinem erste Post bereits gegeben ;).
Aber das ist ja jetzt eh egal
mfg
v R
-
@vR n' SideW: warum eigentlich
bool checkPasswd(std::string &password)
und nicht call-by-value oder Übergabe von konstantem Obj (read-only-Bez) ??