Help! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help!

hi everyone...
i am in grade 11 at a college in australia and i was wondering if i could get a little help with an assignment i am having trouble with..

what i need to know is:

what is the appropriate coding to put password security on a program i am making? the password for the program needs to be 6 characters (numbers only) long and the user has three attempts access the program with the correct code before it terminates.

i would be sooo grateful if you could help me with this..

Thankyou very much!
-Natalia

Comments

  • zibadianzibadian Posts: 6,349Member
    : hi everyone...
    : i am in grade 11 at a college in australia and i was wondering if i could get a little help with an assignment i am having trouble with..
    :
    : what i need to know is:
    :
    : what is the appropriate coding to put password security on a program i am making? the password for the program needs to be 6 characters (numbers only) long and the user has three attempts access the program with the correct code before it terminates.
    :
    : i would be sooo grateful if you could help me with this..
    :
    : Thankyou very much!
    : -Natalia
    :
    :
    The three tries can be best coded using a repeat until loop and a counter. If the user gives the correct password or the counter reaches a certain number the loop ends. Then you need check the password again to see if the user may continue with the program. This second check is nearly always an simple if-then. Should the user fail the password check, simply call the TApplication.Terminate method. This will gracefully terminate your program.
    Storing the password is somewhat more difficult. You ought to come up with a very elaborate routine, which takes the numbers and changes them in such a way that it will be hard to get them back again. Here is a very simple encryption example:
    [code]
    for i := 1 to Length(Password) do
    Password[i] := char(byte(Password)+1);
    [/code]
    This code shifts each character in the password 1 place up, so A becomes B, B becomes C, etc. This is quite unsecure, but for learning purposes it can be used. After you have secured your password, you can use a simple textfile to store it on the disk. You could even consider storing it as a constant in your code, although changing the password after the program is compiled will be more difficult.
  • netgertnetgert Posts: 331Member
    : : hi everyone...
    : : i am in grade 11 at a college in australia and i was wondering if i could get a little help with an assignment i am having trouble with..
    : :
    : : what i need to know is:
    : :
    : : what is the appropriate coding to put password security on a program i am making? the password for the program needs to be 6 characters (numbers only) long and the user has three attempts access the program with the correct code before it terminates.
    : :
    : : i would be sooo grateful if you could help me with this..
    : :
    : : Thankyou very much!
    : : -Natalia
    : :
    : :
    : The three tries can be best coded using a repeat until loop and a counter. If the user gives the correct password or the counter reaches a certain number the loop ends. Then you need check the password again to see if the user may continue with the program. This second check is nearly always an simple if-then. Should the user fail the password check, simply call the TApplication.Terminate method. This will gracefully terminate your program.
    : Storing the password is somewhat more difficult. You ought to come up with a very elaborate routine, which takes the numbers and changes them in such a way that it will be hard to get them back again. Here is a very simple encryption example:
    : [code]
    : for i := 1 to Length(Password) do
    : Password[i] := char(byte(Password)+1);
    : [/code]
    : This code shifts each character in the password 1 place up, so A becomes B, B becomes C, etc. This is quite unsecure, but for learning purposes it can be used. After you have secured your password, you can use a simple textfile to store it on the disk. You could even consider storing it as a constant in your code, although changing the password after the program is compiled will be more difficult.
    :
    a better idea would be to do some airthmetic operations with the password (with each character's ordinal value) and generate a hash, either 8-bit, 16-bit or 32-bit. then you just generate a hash of the real password, store it as Integer/Cardinal, and for every attempt create hash of that password and compare the value to the real password's hash
    im just font of hashs :-D
    [hr][red][italic][b]N[/b][/red][blue]et[/blue][red][b]G[/b][/red][blue]ert[/italic][/blue][hr]

Sign In or Register to comment.