Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 23
  1. #1
    Join Date
    Jan 2008
    Posts
    10

    Password through text file

    Hello every one.

    actually we all - may be not- know how to create password, but could any one please tell me

    how to make password through separate text file

    like I have password " indigo" and wanna save it as text file - pass.txt - under system root or whereever. and my project will read the file

    thanx in advanced for help.
    Mr.Said

  2. #2
    Join Date
    Jan 2007
    Posts
    271

    This might help.

    Hi Mr.Said,

    Create your test.txt file (put your password in the text file)
    Place it in C:\\

    Create Page 1 and Duplicate.

    Put this On Preload of Page 1 Properties
    Code:
    -- Read the contents of a text file to a table.
    tabText = TextFile.ReadToTable("C:\\test.txt");

    Put this On Show of Page 1 Properties
    Code:
    --assume the user enters a bad password
    correct_password = false;
    
    -- the 'correct' password
    real_passwords = tabText;
    
    -- prompt the user to enter a password
    user_password = Dialog.PasswordInput("Password", "Please enter the password: ", MB_ICONQUESTION);
    
    -- compare the user's password to the 'correct' password.
    for j in real_passwords do
        if real_passwords[j] == user_password then
            correct_password = true;
    Page.Jump("Page2")
        end
    end
    
    --if the password was bad, exit
    if not correct_password then
        Application.Exit();
    end

    AudioSam
    Last edited by AudioSam; 01-31-2008 at 04:01 AM.

  3. #3
    Join Date
    Jan 2007
    Posts
    271

    Another way.

    Actually the block of code for Preload could go above
    the code Page 1 On Show.

    AudioSam

  4. #4
    Join Date
    Jan 2007
    Posts
    271

    Arrow This does everything on Page 1

    Hi Mr.Said,



    Create your test.txt file (put your password in the text file)
    Place it in C:\\

    Create Page 1
    Put this On Show of Page 1 Properties


    Code:
    -- Read the contents of a text file to a table.
    tabText = TextFile.ReadToTable("C:\\test.txt");
    if tabText[2] == "RegistrationComplete"  then
    Application.ExitScript()
    end
    
    --assume the user enters a bad password
    correct_password = false;
    -- the 'correct' password
    real_passwords = tabText;
    -- prompt the user to enter a password
    user_password = Dialog.PasswordInput("Password", "Please enter the password: ", MB_ICONQUESTION);
    
    -- compare the user's password to the 'correct' password.
    for j in real_passwords do
        if real_passwords[j] == user_password then
            correct_password = true;
            
    tabText = {""}; 
    Table.Insert(tabText, 2, "RegistrationComplete");
    TextFile.WriteFromTable("C:\\test.txt", tabText, true)
    end
    end
        
    --if the password was bad, exit
    if not correct_password then
        Application.Exit();
    
    end
    No more changes....
    AudioSam

  5. #5
    Join Date
    May 2006
    Posts
    5,380

    Star Security Alert !!

    No more changes....
    lol, just one more

    if you are going to store a password in a file then either the password or the file needs to be encrypted else hacking the pw will be like candy+baby!.....just my 2 pence

    Hey Audio, i see you are getting it together with this coding lark, now you able to help others
    Open your eyes to Narcissism, Don't let her destroy your life!!

  6. #6
    Join Date
    Jan 2007
    Posts
    271

    Hello Rizla

    Where do I start....
    About encrypting....
    I'll leave that to you guys to tell them how.
    I tried to help with what Bruce had posted.
    Man , I butchered that up in an all night fight.
    The thing about trying is it makes me look like an idiot when I fail.
    I only missed a whole nights sleep trying to figure it out.
    All that just to make him mad...
    Anyway, I am understanding some things a little better.
    On this password file.
    I took what Mr. Said to be so that once someone put in a password
    they wouldn't have to keep putting it in.
    In that case no one else would need a password because the App
    would be open to anyone.
    I see what your thoughts would be though.
    Thanks for keeping me in line.
    Now I have to dig into how to encrypt a file
    while loosing 12 hours of sleep...

    Later m8,
    AudioSam

  7. #7
    Join Date
    Jan 2008
    Posts
    10

    Thumbs up Great result

    Hello guys.

    I am really very thankful to you cause I didnt have anytime to try any code but I come now to see the great result.

    thank you very much for such effort YOU did for me "AudioSam"

    how much you would like to get for that

    you really did what I want but also you could do the encrypting to have the final result

    many many many thanks for you all overthere

  8. #8
    Join Date
    Jan 2008
    Posts
    10

    but .... try to pres ok without password

    Hello guys.


    but the funn in this code is if you press on OK without putting a password then it ll go on without problem
    it need to be solved right

    it means no need to hack it, just enter

  9. #9
    Join Date
    May 2006
    Posts
    5,380
    just need to check for no-text or cancel button


    Code:
    -- Read the contents of a text file to a table.
    tabText = TextFile.ReadToTable("C:\\test.txt");
    if tabText[2] ~= "RegistrationComplete"  then
    	--assume the user enters a bad password
    	correct_password = false;
    	-- the 'correct' password
    	real_passwords = tabText;
    	-- prompt the user to enter a password
    	user_password = Dialog.PasswordInput("Password", "Please enter the password: ", MB_ICONQUESTION);
    	-- check that some text was enterd and cancel wasent clicked
    	if user_password ~= "" and user_password ~= "CANCEL" then
    		-- compare the user's password to the 'correct' password.
    		for j in real_passwords do
    		    if real_passwords[j] == user_password then
    		        correct_password = true;
    				tabText = {""}; 
    				Table.Insert(tabText, 2, "RegistrationComplete");
    				TextFile.WriteFromTable("C:\\test.txt", tabText, true)
    			end
    		end
    	 end  
    	--if the password was bad, exit
    	if not correct_password then
    	    Application.Exit();
    	end
    end
    ^^ untested code

    its the same as AudioSam's code just rearranged

    I butchered that up in an all night fight.
    The thing about trying is it makes me look like an idiot when I fail.
    Dont be so hard on you, i shot myself in the foot loads when i first started giving help here, just made me think about what i was doing more and try to find the best solution to the problem
    Open your eyes to Narcissism, Don't let her destroy your life!!

  10. #10
    Join Date
    Jan 2008
    Posts
    10

    going to be good

    well I think now we won over OK button, but the questen is:

    why the program needs to ask the password since it is saved in the file test.txt.

    and if you try to delete the file see what ll happen, you could enter the project.

    my sweet regards.

  11. #11
    Join Date
    Jan 2007
    Posts
    271

    Mr. Said

    I tried the delete the file and I see it does allow app to run.
    I will look at that, I think it's an easy fix.

    Are you wanting this so that a user has to enter the password
    every time or only once and then the app will open from then on
    with out password?

    I am not nearly as good as many others in the forum
    but I will try to help.

    AudioSam

  12. #12
    Join Date
    Jan 2007
    Posts
    271

    Arrow This works. Maybe Rizla can help with encryption.

    Place your test.txt file in your Apps Docs Folder with
    your password in the text file.

    Same as earlier, Place this code in Page/On Show

    Code:
    File.Copy("AutoPlay\\Docs\\test.txt", "C:\\test.txt", false, false, false, true)
    IFT = File.DoesExist("C:\\test.txt")
    if IFT == false then
    Dialog.Message("Error", "A Critical File has been removed, Please contact Vendor", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
    Application.Exit()
    else
    end
    -- Read the contents of a text file to a table.
    tabText = TextFile.ReadToTable("C:\\test.txt");
    if tabText[2] ~= "RegistrationComplete"  then
    	--assume the user enters a bad password
    	correct_password = false;
    	-- the 'correct' password
    	real_passwords = tabText;
    	-- prompt the user to enter a password
    	user_password = Dialog.PasswordInput("Password", "Please enter the password: ", MB_ICONQUESTION);
    	-- check that some text was enterd and cancel wasent clicked
    	if user_password ~= "" and user_password ~= "CANCEL" then
    		-- compare the user's password to the 'correct' password.
    		for j in real_passwords do
    		    if real_passwords[j] == user_password then
    		        correct_password = true;
    				tabText = {""}; 
    				Table.Insert(tabText, 2, "RegistrationComplete");
    				TextFile.WriteFromTable("C:\\test.txt", tabText, true)
    			end
    		end
    	 end  
    	--if the password was bad, exit
    	if not correct_password then
    	    Application.Exit();
    	end
    end
    There are different ways to do this.
    If your setting it up to send the user a password
    it would be different than this.
    let us know.
    AudioSam
    Last edited by AudioSam; 02-01-2008 at 06:50 AM.

  13. #13
    Join Date
    Jan 2008
    Posts
    10
    actually I would like the app to lunch dirctlly without even putting password,just check if the text file has same password as it is saved inside the app.

    no need to give any one password,just they play.
    beside I wanna place the text file out of the app. in case it got lost there ll be no access to the text file, or no expectation where will it be!

    thanks alot for such great help

  14. #14
    Join Date
    Jan 2007
    Posts
    271

    Mr.Said

    Would it work to just send them a password and once they enter it one
    time they won't be asked again?
    If that would work you don't really need to reference it outside of the App.
    Just send an email or whatever with the password they would enter one time.
    Let us know.
    AudioSam
    I see ya Rizla.... : )

  15. #15
    Join Date
    May 2006
    Posts
    5,380
    Why not use Application.SaveValue to get rid of the text file altogether, and you really need to encrypt the password

    Try This:

    1st run it will ask for a master password for the app, if entered ok then it will encrypt it and save it to the registry and run the app.

    2nd (or any run after the first) if will read the encrypted password from the registry and compare it to the one entered by the user, if it dosent match then exit the app

    Pug in page preload or project startup
    Code:
    blnAllow = false
    -- Get the encrypted password
    cptPassword = Application.LoadValue("Your_Application_Name", "Password");-- ENTER YOUR APP NAME HERE
    -- Check that the password exists
    if cptPassword ~= "" then
    	-- Password dose exists so ask the user to enter access pass
    	strUserData = Dialog.Input("Enter Password", "Please enter your password:", "", MB_ICONQUESTION);
    	-- Check that a password was enterd
    	if strUserData ~= "" and strUserData ~= "CANCEL" then
    		-- Decrypt our saved password
    		uncptPassword = Crypto.BlowfishDecryptString(cptPassword, "trustno1withthispassword");-- ENTER YOUR ENCRYPTION PASSWORD HERE
    		-- Now check the user password to the saved password
    		if strUserData == uncptPassword then
    			-- Is a match so allow app to run
    			blnAllow=true
    		else
    			-- Was not a match so ask again
    			blnAllow=false
    		end
    	else
    		blnAllow=false
    	end
    else
    	-- Password dose not exist
    	strUserData = Dialog.Input("Enter Password", "Please enter a master password you would like to use:", "", MB_ICONQUESTION);
    	-- Check that a password was enterd
    	if strUserData ~=  "" and strUserData  ~= "CANCEL" then
    		-- password was enterd so encrypt it
    		cptPassword = Crypto.BlowfishEncryptString(strUserData, "trustno1withthispassword", 0);-- ENTER YOUR ENCRYPTION PASSWORD HERE
    		-- Now save it and allow the app to run
    		Application.SaveValue("Your_Application_Name", "Password", cptPassword);-- ENTER YOUR APP NAME HERE
    		blnAllow=true
    	else
    		blnAllow=false
    	end
    end 
    
    if blnAllow == false then
    	Application.Exit(0);
    end
    Open your eyes to Narcissism, Don't let her destroy your life!!

Page 1 of 2 1 2 LastLast

Similar Threads

  1. reading from text file
    By tstadheim in forum AutoPlay Media Studio 5.0
    Replies: 1
    Last Post: 02-09-2004, 03:09 PM
  2. problems parsing text file...
    By Martin_SBT in forum AutoPlay Media Studio 5.0
    Replies: 3
    Last Post: 02-02-2004, 01:16 PM
  3. Writing Text to a File
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 09-22-2003, 02:02 PM
  4. Reoccurring password
    By Bruce in forum AutoPlay Media Studio 4.0
    Replies: 6
    Last Post: 06-04-2003, 04:09 PM
  5. HOWTO: "Hide" Externally Referenced Files
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-23-2002, 03:19 PM

Posting Permissions

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