Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Simple hash algorithm

Altera_Forum
Honored Contributor II
1,162 Views

Hi guys, 

 

I'm trying to create a hash algorithm (a very simple one) for homework exercise. 

 

I basically have taken an input from the user and hash it using: 

 

a = 1, b =2, c = 3 ... z = 26. 

 

So if the user input is abc, it will store 123. 

 

My functions for creating a username and password so far: 

// registering an account void regAccount(){ cout << "Please enter your username: "; cin >> inputUsername; cout << endl; if (inputUsername == username || inputUsername == username || inputUsername == username || inputUsername == username || inputUsername == username || inputUsername == username || inputUsername == username || inputUsername == username || inputUsername == username || inputUsername == username) { cout << "Username already exists" << endl; } else { for (i = 0; i < 10; i++) { if (username == "Empty") { username = inputUsername; hashPass(); cout << "Is this account an admin? - 1 = yes / 2 = no: "; cin >> input; if (input == 1) { admin = true; } else { admin = false; } break; } } } }// hash the passwordvoid hashPass(){ cout << "Please enter your password: "; cin >> password; cout << endl; for (int j = 0; j < password.length(); j++) { // possibly a switch statement checking if password == a, b, c... } } 

Thanks for having a look. 

 

 

 

_____________________________________ 

best ringtones download (http://bestringtones.net) on this website is including all the best ringtones, the latest, most are much loved and the best quality. When you have the best ringtones, you will feel happy and comfortable. 

 

0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
445 Views

Hello 

 

for (int i=0;i<strlen(username);i++) 

username=username-'a'+1; 

 

Best regards 

Johi
0 Kudos
Reply