Results 1 to 2 of 2

Thread: Simple hash algorithm

  1. #1
    Join Date
    Feb 2017
    Posts
    2
    Rep Power
    1

    Default Simple hash algorithm

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

    Thanks for having a look.



    _____________________________________
    best ringtones download 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.

    Last edited by vickywin; March 17th, 2017 at 11:23 PM.

  2. #2
    Join Date
    Dec 2015
    Location
    Belgium
    Posts
    124
    Rep Power
    1

    Default Re: Simple hash algorithm

    Hello

    for (int i=0;i<strlen(username);i++)
    {
    username[i]=username[i]-'a'+1;
    }

    Best regards
    Johi

Similar Threads

  1. TSE Multicast Hash table issue
    By dcattley in forum General Discussion Forum
    Replies: 6
    Last Post: May 28th, 2015, 06:19 AM
  2. Error (10481):Keccack hash functions
    By nissi in forum General Altera Discussion
    Replies: 1
    Last Post: September 24th, 2013, 12:41 PM
  3. Architecture/VHDL code for Hash Table IP Lookup
    By ZAMAI in forum IP Discussion
    Replies: 1
    Last Post: March 14th, 2011, 04:26 AM
  4. Comparisin Between QRD-RLS algorithm and MUSIC algorithm
    By prasanna in forum DSP Builder and DSP IPs
    Replies: 0
    Last Post: June 21st, 2009, 09:53 PM
  5. kernel terminal after it shows PID hash ...
    By yongxiangcn in forum Linux Forum
    Replies: 2
    Last Post: January 5th, 2007, 04:45 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •