Announcement

Collapse
No announcement yet.

Hiding Passwords

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Kim Peck
    replied
    good point, i wasn't really thinking.

    Code:
    if len(pword$)>0 then
       x=pos
       locate , x-1 : print " ";
       locate , x-1
       pword$=left$(pword$, len(pword$)-1)
    else
       beep
    end if
    ------------------


    [This message has been edited by Kim Peck (edited October 10, 2003).]

    Leave a comment:


  • Mel Bishop
    replied
    Originally posted by Kim Peck:
    Code:
    x=pos
    locate , x-1 : print " ";
    locate , x-1
    pword$=left$(pword$, len(pword$)-1)
    Should work quite nicely, Kim. Please don't forget to add code
    to take into account that X may wind up being zero and pword$
    might wind up being a null string. Pressing B/S under those
    circumstances......

    That's the main reason I didn't include it in the first place.
    What with me typing off the cuff, wouldn't have a chance to
    debug it.



    ------------------

    Leave a comment:


  • Kim Peck
    replied
    'backspace code for mel's little program:

    Code:
    x=pos
    locate , x-1 : print " ";
    locate , x-1
    pword$=left$(pword$, len(pword$)-1)

    please note that i'm kinda new to pb and i wrote this here
    without any sort of testing, just in case there's an error .

    ------------------


    [This message has been edited by Kim Peck (edited October 10, 2003).]

    Leave a comment:


  • Mel Bishop
    replied
    A little simpler approach (typing off the cuff, so...)
    Code:
    h = 0
    pword$ = ""
    do
    while instat=0
    'other processing here as needed
    wend
    an$ = inkey$
    h = asc(an$)
    if h = 13 or h = 27 then exit loop  'Cr or ESC
    
    if h = 8 then                       'Backspace
    'backspace code needed here
    end if
    
    if h > 31 and h < 128 then          'printable only
    pword$ = pword$ + an$
    print;"*";
    end if
    loop



    [This message has been edited by Mel Bishop (edited September 30, 2003).]

    Leave a comment:


  • Matthew Berg
    replied
    Try the following example:
    Code:
    REM ********************************************************************************
    REM *                        Hidden Text Input Example Code                        *
    REM *                  This code is released to the Public Domain                  *
    REM ********************************************************************************
    $DIM ALL
     
    DECLARE FUNCTION GetHiddenInput( BYVAL STRING, BYVAL STRING ) AS STRING
    DIM sText AS STRING
     
    CLS
    LET sText = GetHiddenInput( "Enter text: ", "*" )
    PRINT
    PRINT "You entered the string " + CHR$( 34 ) + sText + CHR$( 34 )
     
    END
     
    FUNCTION GetHiddenInput( _
    	BYVAL sPrompt AS STRING, _
       BYVAL sHiddenChar AS STRING ) PRIVATE AS STRING
     
       DIM sChar AS STRING
       DIM sInput AS STRING
     
       'Display prompt
       PRINT sPrompt;
       LOCATE , , 1
     
       'Process input
       LET sChar = INKEY$
       WHILE sChar <> CHR$( 13 )
       	IF LEN( sChar ) > 0 THEN
    			SELECT CASE sChar
    	      	CASE CHR$( 8 )
    	         	IF LEN( sInput ) > 0 THEN
    	            	LET sInput = LEFT$( sInput, LEN( sInput ) - 1 )
    	               LOCATE , LEN( sPrompt ) + 1, 0
    	               PRINT STRING$( LEN( sInput ) * LEN( sHiddenChar ), sHiddenChar ) + SPACE$( LEN( sHiddenChar ) );
    	               LOCATE , LEN( sPrompt ) + 1 + ( LEN( sInput ) * LEN( sHiddenChar ) ), 1
    	            ELSE
    	            	BEEP
    	            END IF
    	         CASE ELSE
    	         	LET sInput = sInput + sChar
    	            PRINT STRING$( LEN( sHiddenChar ), sHiddenChar );
    	      END SELECT
          END IF
     
          LET sChar = INKEY$
       WEND
     
       FUNCTION = sInput
     
    END FUNCTION
    Please note that this example makes no allowance for wrapping that might occur if you type a string too big for one line, or for scrolling that might occur if you are entering text at the bottom of the screen. It also has onlya minimum of editing capabilities (backspace to delete the last character).

    HTH.

    ------------------
    If you try to make something idiot-proof, someone will invent a better idiot.

    Leave a comment:


  • Keith E. Black
    started a topic Hiding Passwords

    Hiding Passwords

    How do I produce asterisks to hide a password from someone looking over my shoulder.
    I have tried the "color 15,15" approach, but sometimes forget how many more spaces
    I need to complete the password. I am using the PB 3.5 compiler.
    Any help will be appreciated. Thanks.

    ------------------
Working...
X