Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using Qt creator ide with pure c++ coding. I need to create a class with 2 member variables A & B (also added in the table)and 3 public and private functions.
public functions: to check whether database exists ,if exists open and read data A & B else call the 3 functions from private.2nd function is to generate a 26 char array and store in 25 digit no. using srand() return it - getA().3rd function is to take sha256 hash concating 2nd function + timestamp - getB().
Private functions: to create an sqlite database,to initialise a basic table structure (char A|char B|blob C).3rd functon is to generate details to store to databse and also to A & B. both getA() and getB() is called from this function to generate details.

How can i define the public functions mentioned in the question ( using srand() & sha256 library) ?
Updated 12-Feb-14 23:17pm
amzz 13-Feb-14 2:15am    
Jochen Arndt 13-Feb-14 3:12am    
Nobody here will do it all for you, especially when it is homework. You should start by writing the class and then come back if you have a specific question on a particular problem.
amzz 13-Feb-14 5:13am    
I have created the class and have done the database operations . how do i generate these public functions( mainly using srand() & sha256 library )?
Jochen Arndt 13-Feb-14 5:35am    
OK. That narrows it down. However, your problem is not really clear. You should try to rephrase your question by adding some more information (use the green 'Improve question' link).

It might be (as far as I understand you):
How do I generate a string containing 25 random digit characters using srand(). Using this string and a time stamp, I have to generate a SHA256 hash. How can I do that.

You may also show the code you have written so far that is related to the problems. Other code (like the database operations) is not necessary.

All this increases the chance to get an answer.

A quick answer from me:
Use srand() to generate digits and print the result to a string (you may generate 25 digits in the range 0 to 9 or numbers with more digits).
For SHA256, google for 'sha hash generator' or 'sha library'. When using Linux, you may use the openssl library.
thatraja 13-Feb-14 3:13am    
Agree with Jochen Arndt

1 solution

Jochen Arendt is right to google for these functions. They are standard function, so spending time to learn it is well invested.

My tip is, to write for every operation a own function with a good name. Like "CheckDatabaseExist" and so on. And return a value and check it for the next step.

good luck for your homework :-)
(for questions show code and output)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900