Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Input hiding (different from password hiding)  (Read 29325 times)

0 Members and 1 Guest are viewing this topic.

Dias de verano

  • Guest
Re: Input hiding (different from password hiding)
« Reply #30 on: April 20, 2009, 12:50:17 AM »
Source code for program attached to post previously.

Code: [Select]

' password collector
password$ = ""
mask$ = "*"
PRINT "Enter password : ";
DO
        DO
                k$ = INKEY$
        LOOP UNTIL k$ <> ""
        kval = ASC(k$)
        IF kval = 13 THEN
                PRINT
                EXIT DO
        ELSE
                PRINT mask$;
                password$ = password$ + k$
        END IF
LOOP
OPEN "Password.txt" FOR OUTPUT AS #1
PRINT #1, password$
CLOSE #1
SYSTEM               


The only thing I had to do to make it work in both Freebasic and QBasic was to change this line

Code: [Select]
                password$ = password$ + k$
the + string concatenation symbol is accepted by both compilers/interpreters, but the & character, which I at first used, only works in Freebasic.

Refinements might be to pass the wording of the prompt, the masking character, and the output filename as parameters. Possibly it might be better to avoid using a file for the typed characters by outputting the typed in text to stdout and using FOR to swallow it. However it's just a toy program so maybe there's not much point in all of that.

Also maybe it would be better, in the calling batch, to overwrite the file containing the typed in password, rather than just deleting it. E.g.

echo Hello World>password.txt



Reno



    Hopeful
  • Thanked: 32
    Re: Input hiding (different from password hiding)
    « Reply #31 on: April 20, 2009, 01:57:59 AM »
    I remember there was one member a year ago with "dog" in their username that was good with VBScript.
    i am sure it's not ghostdog.
    madcad, i don't know where you get the idea that ghostdog is good at vbscript.
    he even can't solve a simple coding requirement:
    http://www.computerhope.com/forum/index.php/topic,79825.msg526693.html#msg526693
    he only have a lot of generic code from google, but don't have the ability to modify it.

    until the day this forum specifically prohibits any kind of tools/languages to use except batch solution, you just have to suck it up.
    i don't think it's prohibited, when OP ask for a simple batch solution, i've seen too many reply of get a unix tools, and actually sick of it. for this password masking question, it's impossible to do in only batch, so there is some solution posted using .com,freebasic, qbasic, etc, so it's not prohibited.

    as for your other comment, i can only say, I advocate using right tools for the job ->> productivity.
    a tool is only useful in the right hand. the lack of creativity, logic thinking & coding ability does not result in high productivity even various tools is used.

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Input hiding (different from password hiding)
    « Reply #32 on: April 20, 2009, 02:25:23 AM »
    This thread has gone far too long. But it draws lots of lookers.
    This has all been done years ago and beaten into the ground. And if that was not enough, now we want to break off its tail after chasing it into shallow hole.
    Look at Bill Stewart's Site :
    Quote
    How do I get user input in a batch file?
    There are 3 basic answers to this question. The first one is my favorite because 1) I wrote the programs and 2) they provide the greatest amount of flexibility.
    http://www.westmesatech.com/cmdprompt.html
    And there are many others, who knows who did it first.

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Input hiding (different from password hiding)
    « Reply #33 on: April 20, 2009, 02:43:24 AM »
    Quote
    he even can't solve a simple coding requirement:
    http://www.computerhope.com/forum/index.php/topic,79825.msg526693.html#msg526693


    I don't see anybody else making an effort.

    I have to agree that it get's old recommending various scripting languages all over the place, but that's no reason to try to shoot down a solution he provided- even if it doesn't meet the requirements- because his posts were the only ones trying to help the original poster.

    yours just complain about it not working, and Dias's is telling you to calm down. A sentiment I must agree with.
    I was trying to dereference Null Pointers before it was cool.

    Batcher



      Rookie

      Thanked: 5
      Re: Input hiding (different from password hiding)
      « Reply #34 on: April 20, 2009, 02:43:56 AM »
      Code: [Select]
      @echo off
      set RealPwd=Batcher
      >"%temp%\GetPwd.vbs" echo WScript.Echo CreateObject("ScriptPW.PassWord").GetPassWord
      set /p=Enter password: <nul
      for /f %%a in ('cscript //nologo "%temp%\GetPwd.vbs"') do (
        set "InputPass=%%a"
      )
      echo.
      if "%InputPass%" equ "%RealPwd%" (
        echo Correct password.
      ) else (
        echo Incorrect password.
      )
      pause

      gh0std0g74



        Apprentice

        Thanked: 37
        Re: Input hiding (different from password hiding)
        « Reply #35 on: April 20, 2009, 03:13:58 AM »
        i don't think it's prohibited, when OP ask for a simple batch solution, i've seen too many reply of get a unix tools, and actually sick of it. for this password masking question, it's impossible to do in only batch, so there is some solution posted using .com,freebasic, qbasic, etc, so it's not prohibited.
        dude, the replies  and solutions i posted is for the OP. the one to get sick or not is not you, but the OP. Oh, so you mean doing something in Freebasic, qbasic and converting it to exe and then putting it into a batch file is ok, but using tools like gawk.exe or sed.exe is not ok? I can convert the Perl code i posted to exe too, does that count? why don't you think out of the box?

        Quote
        a tool is only useful in the right hand. the lack of creativity, logic thinking & coding ability does not result in high productivity even various tools is used.
        its worse when you have creativity, logic thinking & coding ability but without a good tool to use.
        I am just about done with you. the last thing i want to say to you, if you are so free (to get sick), why don't you go fly a kite?

        macdad-



          Expert

          Thanked: 40
          Re: Input hiding (different from password hiding)
          « Reply #36 on: April 20, 2009, 05:53:25 AM »
          No, no there was one person about a year ago who was good at VBScript.
          If you dont know DOS, you dont know Windows...

          Thats why Bill Gates created the Windows NT Family.

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: Input hiding (different from password hiding)
          « Reply #37 on: April 20, 2009, 11:21:28 AM »
          Dear Topic St artier,  R U still there?

          Hello, perhaps I had been hard or unkind.  Please accept my apology.
          Your code is difficult to understand.  Good programming practice is to comment code and break it into smaller parts so as to help others to understand what you're doing.  Also, when you go back to your code months later it will be easy to understand why you did a certain thing.
          Yesterday originally the batch commands were intended for simple jobs like to to copy files to rename files and in find a certain types of files in the directories.  Later, Microsoft added some more features to the command set.  Many of these were simply extensions for code that was already inside the command interpreter.  However, the extensions were not what we would call elegance or intuitive.  The ability to search for substrate in the command line or again a text file is a rather awkward feature of the command language.  It helps if there is a notation that helps others understand what you are doing when you're looking for substrate.
          Also, the command language does not have, by itself, a graceful way to take input from the user.  So some external program is often used for this purpose, one of these was the program called choice.com, which is not inside a the command interpreter, is actually another program that stands by itself.
          To solve the password hiding questions, or any situation where you want to hide the user input, many programmers will suggest using one of the external programs to take the user input and either showed or nonchalant according to some switches the program accept.
          Of course, there is awaited the using just the things that are inside the badge commands.  But some today's parts so on orange furor that many people would choose not to do it that way.
          A few years ago when MS-DOS was very popular people use the are ANSI system to write colorful images in the upper left corner every time he got a prompt.  Sometime later this sort of thing faded from use, and she decided to become more familiar with a graphical user interface of Windows and no longer were interested in drawing pictures on the screen inside a DOS.  However, the graphical capabilities of the ANSI system would make it possible for you to hide the user input and thus that would be one way to solve this problem.  And it would not require any external programs.  But it would require that the DOS would have to love the ANSI system before the station started.
          Well, that is the end of my lecture for today.  Thank you for listening.
          By the way, any funny spelling or grammar is due to the speech recognition program.  When I some long lecture together I give up on trying to the user keyboard.  Bye for now.







          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: Input hiding (different from password hiding)
          « Reply #38 on: April 20, 2009, 11:23:43 AM »
          Quote
          By the way, any funny spelling or grammar is due to the speech recognition program.  When I some long lecture together I give up on trying to the user keyboard.  Bye for now.


          AHHH! Now it all makes sense.

          that explains a lot of spelling/weird words in some of your previous posts.
          I was trying to dereference Null Pointers before it was cool.

          Dias de verano

          • Guest
          Re: Input hiding (different from password hiding)
          « Reply #39 on: April 20, 2009, 11:42:27 AM »
          either showed or nonchalant

          Monsieur Geek - 21h00 du soir, je pense que votre langue maternelle n'est pas l'anglais. Est-ce-que j'ai raison ?

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: Input hiding (different from password hiding)
          « Reply #40 on: April 20, 2009, 11:45:43 AM »
          I'm pretty sure that's french. something about his mother's native language? or Mother tongue?

          I was trying to dereference Null Pointers before it was cool.

          macdad-



            Expert

            Thanked: 40
            Re: Input hiding (different from password hiding)
            « Reply #41 on: April 20, 2009, 11:48:26 AM »
            Back on topic...

            If you dont know DOS, you dont know Windows...

            Thats why Bill Gates created the Windows NT Family.

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: Input hiding (different from password hiding)
            « Reply #42 on: April 20, 2009, 11:58:16 AM »
            back on topic indeed.

            my latest compile of BCScript and BASeParser XP have the ability to prompt for input via a password without any extra code. Just pass a pw character, and it does the rest.
            I was trying to dereference Null Pointers before it was cool.

            Geek-9pm


              Mastermind
            • Geek After Dark
            • Thanked: 1026
              • Gekk9pm bnlog
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: Input hiding (different from password hiding)
            « Reply #43 on: April 20, 2009, 12:02:37 PM »
            Quote
            Monsieur Geek - 21h00 du soir, je pense que votre langue maternelle n'est pas l'anglais. Est-ce-que j'ai raison ?

            Voici est 11: AM et il est vrai, je suis un homme parlant anglais america. Est-ce que cela a un sens?

            Dias de verano

            • Guest
            Re: Input hiding (different from password hiding)
            « Reply #44 on: April 20, 2009, 12:45:40 PM »
            Voici est 11: AM et il est vrai, je suis un homme parlant anglais america. Est-ce que cela a un sens?

            Je crois que chez vous l'heure est 11 du matin, mais votre nom d'écran se traduit comme "geek-21h00".

            Vous parlez anglais américain, mais vous écrivez un peu comme quelqu'un qui parle une langue derivée du Latin.

            Et de temps en temps, vous écrivez comme quelqu'un qui vient d'une autre planète:

            Quote
            But some today's parts so on orange furor