Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef BZF_MD5_H
- #define BZF_MD5_H
- #include <regex>
- #include <termios.h>
- #include <unistd.h>
- #include <iostream>
- #include <iomanip>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string>
- #include <iostream>
- class MD5
- {
- public:
- typedef unsigned int size_type; // must be 32bit
- MD5();
- MD5(const std::string& text);
- void update(const unsigned char *buf, size_type length);
- void update(const char *buf, size_type length);
- MD5& finalize();
- int getch(void);
- std::string getUserPassword(const char *prompt, bool show_asterisk);
- std::string hexdigest() const;
- std::string md5() const;
- friend std::ostream& operator<<(std::ostream&, MD5 md5);
- ........
- /* interface header */
- #include "md5.h"
- /* system implementation headers */
- #include <stdio.h>
- #include <string.h>
- std::string getUserPassword(const char *prompt, bool show_asterisk=true)
- {
- const char BACKSPACE=127;
- const char RETURN=10;
- std::string password;
- unsigned char ch=0;
- //cout <<prompt<<endl;
- while((ch=getch())!=RETURN)
- {
- if(ch==BACKSPACE)
- {
- if(password.length()!=0)
- {
- if(show_asterisk)
- std::cout <<"b b";
- password.resize(password.length()-1);
- }
- }
- else
- {
- password+=ch;
- if(show_asterisk)
- std::cout <<'*';
- }
- }
- std::cout << std::endl;
- return password;
- }
- .........
- **main.cpp**
- #include "md5.h"
- #include <string>
- #include <iostream>
- using namespace std;
- int main() {
- string str = getUserPassword("Enter the password: ",true);
- ..........
- root@kali:~/Desktop/md51# g++ main.cpp md5.cpp -o a
- main.cpp: In function ‘int main()’:
- main.cpp:7:17: error: ‘getUserPassword’ was not declared in this scope
- string str = getUserPassword("Enter the password: ",true);
- ^~~~~~~~~~
- main.cpp:7:17: note: suggested alternative: ‘union’
- string str = getUserPassword("Enter the password: ",true);
- ^~~~~~~~~~
- union
Add Comment
Please, Sign In to add comment