Guest User

Untitled

a guest
Dec 12th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. #ifndef BZF_MD5_H
  2. #define BZF_MD5_H
  3. #include <regex>
  4. #include <termios.h>
  5. #include <unistd.h>
  6. #include <iostream>
  7. #include <iomanip>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string>
  11. #include <iostream>
  12.  
  13. class MD5
  14. {
  15. public:
  16. typedef unsigned int size_type; // must be 32bit
  17.  
  18. MD5();
  19. MD5(const std::string& text);
  20. void update(const unsigned char *buf, size_type length);
  21. void update(const char *buf, size_type length);
  22. MD5& finalize();
  23. int getch(void);
  24. std::string getUserPassword(const char *prompt, bool show_asterisk);
  25. std::string hexdigest() const;
  26. std::string md5() const;
  27. friend std::ostream& operator<<(std::ostream&, MD5 md5);
  28.  
  29. ........
  30.  
  31. /* interface header */
  32. #include "md5.h"
  33.  
  34. /* system implementation headers */
  35. #include <stdio.h>
  36. #include <string.h>
  37.  
  38. std::string getUserPassword(const char *prompt, bool show_asterisk=true)
  39. {
  40. const char BACKSPACE=127;
  41. const char RETURN=10;
  42.  
  43. std::string password;
  44. unsigned char ch=0;
  45.  
  46. //cout <<prompt<<endl;
  47.  
  48. while((ch=getch())!=RETURN)
  49. {
  50. if(ch==BACKSPACE)
  51. {
  52. if(password.length()!=0)
  53. {
  54. if(show_asterisk)
  55. std::cout <<"b b";
  56. password.resize(password.length()-1);
  57. }
  58. }
  59. else
  60. {
  61. password+=ch;
  62. if(show_asterisk)
  63. std::cout <<'*';
  64. }
  65. }
  66. std::cout << std::endl;
  67. return password;
  68. }
  69.  
  70. .........
  71.  
  72.  
  73.  
  74. **main.cpp**
  75.  
  76. #include "md5.h"
  77. #include <string>
  78. #include <iostream>
  79. using namespace std;
  80. int main() {
  81.  
  82. string str = getUserPassword("Enter the password: ",true);
  83.  
  84. ..........
  85.  
  86. root@kali:~/Desktop/md51# g++ main.cpp md5.cpp -o a
  87. main.cpp: In function ‘int main()’:
  88. main.cpp:7:17: error: ‘getUserPassword’ was not declared in this scope
  89. string str = getUserPassword("Enter the password: ",true);
  90. ^~~~~~~~~~
  91. main.cpp:7:17: note: suggested alternative: ‘union’
  92. string str = getUserPassword("Enter the password: ",true);
  93. ^~~~~~~~~~
  94. union
Add Comment
Please, Sign In to add comment