Hashing troubles

Hi,

I'm trying to write a program that is a calculator that (as an added bonous) will also calculate the md5 hash of a given string of text.

I am having some problems though (read: a lot of problems).

Namely these:

1
2
3
4
5
6
7
8
9
10
71:35 [Warning] multi-character character constant

71 ambiguous overload for 'operator>>' in 'std::cin >> 1835283761' 

73:56 [Warning] multi-character character constant 

74:53 [Warning] multi-character character constant 

74 invalid conversion from `int' to `const char*' 
 



Here is my code, the main problems are in the md5 functions (i am using the library here: http://www.zedwood.com/article/121/cpp-md5-function


Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

#include <cstdlib>
#include <iostream>
#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <unistd.h>
#include <conio.h>
#include <time.h>
#include <ctime>
#include <md5.h>

using namespace std;

int main()
{
    
    
    string close="no";
    while(close=="no")
    {
                      
                      double firstnum;
                      double secondnum;
                      char choice;
                      char md51;
                      
                      
                      cout << "What is the first number?" << endl;
                      cin >> firstnum;
                      cout << "What is the second number?" << endl;
                      cin >> secondnum;
                      cout << "What function would you like to use:" << endl;
                      cout << "1. +" << endl;
                      cout << "2. -" << endl;
                      cout << "3. *" << endl;
                      cout << "4. /" << endl;
                      cout << "5. %" << endl;
                      cout << endl;
                      cin >> choice;
                      if (choice=='1')
                      {
                           cout << firstnum + secondnum << endl;
                      }
                      
                      else if (choice=='2')
                      {
                           cout << firstnum - secondnum << endl;
                      }
                      
                      else if (choice=='3')
                      {
                           cout << firstnum * secondnum << endl;
                      }
                      
                      else if (choice=='4')
                      {
                           cout << firstnum / secondnum << endl;
                      }
                      
//                      else if (choice=='5')
//                      {
//                           cout << (int)firstnum% (int)secondnum% << endl;
//                      }
                      
                      else if (choice=='m')
                      {
                           
                           
                           cout << "Enter somthing here: ";
                           cin >> 'md51';
                           
                           cout << "md5 hash of: " << ('md51') << endl;
                           cout << "Hash: " << md5 ('md51') << endl;
                      }
                      
                      cout <<"Would you like to close the program?" << endl;
                      cin >> close;
                      }
                      system("pause");
                      return EXIT_SUCCESS;
    
}




I am using Dev C++

Thanks,
Stephen
cin >> 'md51'; cin >> is for input. 'md51' is a constant string (would be a constant sstring if it had ". not it has ' and is some sort of crazy char). What do you expect this code to do?
md51 is declared as a char variable, though what you want is a string. Then remove ' ' from it on lines 71, 73, 74.
Hi,

I want the user to be able to enter in the text they want to be hashed.

Thanks,
Stephen
Topic archived. No new replies allowed.