ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Password Character

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

  • Password Character

    Hi All,


    In AS400 when the user enters password, i want to show the password replaced with the Astricks (' * '). Is it possible? If yes how can i do that?

    Thanks.


    Regards,
    Vinothkumar S.
    Regards,
    Vinothkumar S.

  • #2
    Re: Password Character

    not that i'm aware of. you can modify the display but not the actual sign on program which would have to be done in order for you to achieve this.
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      DEMO Pincode with ****

      You could make a pincode or password with ****

      Here is my democode ( proof of concept )

      DDS: PIND

      Code:
      A                                      DSPSIZ(24 80 *DS3)  
      A          R F00                                                    
      A                                  4  6' Demo Asterisk Password '   
      A                                      DSPATR(RI)                   
      A                                  6  7'Enter'                      
      A                                  6 13'PIN'                        
      A            PINNR          1Y 0B  6 17CHECK(ER)                    
      A                                      DSPATR(PC)   
      A                                      EDTCDE(4)                   
      A            PINHIDDEN      4A  O  6 19DSPATR(UL)                   
      A                                      DSPATR(HI)                   
      A                                  8  7'Test For Pincode 1234'      
      A                                  9  7'DSPLY'                      
      A                                 10  5'>'                          
      A            DSPLYPIN       4A  O 10  7

      RPGLE V5R4

      Code:
       ************************************************************************* 
       ** PIN CODE asterisk password DEMO                                     ** 
       ************************************************************************* 
      ** D I S P L A Y                                                           
      FPIND      CF   E             WORKSTN                                      
      ** VARIABLES                                                                                                                                 
      D PINCODE         S              4  0                                      
      ** CLEAR FIELDS   
      C                   CLEAR                   PINHIDDEN                      
      C                   CLEAR                   PINNR                          
      ** LOOP                                                                    
      C                   DOW       PINCODE <> 1234     
      C                   IF        %LEN(%char(PINCODE)) = 4         
      C                   CLEAR                   PINHIDDEN          
      C                   CLEAR                   DSPLYPIN           
      C                   ENDIF                                                               
      C                   EXFMT     F00                                          
      C                   EVALR     PINHIDDEN = %TRIML(PINHIDDEN) + '*'          
      C                   EVAL      DSPLYPIN  = %TRIM(DSPLYPIN) + %char(PINNR)   
      C                   EVAL      PINCODE   = %int(DSPLYPIN)                   
      C                   CLEAR                   PINNR                          
      C                   ENDDO                                                  
      C     'PASSWORD OK' DSPLY                                                  
      C                   SETON                                        LR    
      C                   RETURN
      Let me know what you think of it !
      Last edited by Marc_d; June 18, 2008, 11:49 PM.

      Comment


      • #4
        Re: Password Character

        Hi Marc,

        The code is working Good. Thanks.
        Regards,
        Vinothkumar S.

        Comment


        • #5
          Re: Password Character

          We are all here to learn!

          I just retested my code and noticed that
          when the first PINNR of the PINCODE is zero, it fails.

          &#37;char removes the first zero!

          Code:
          C                   IF        %LEN(%char(PINCODE)) = 4 
          
          you could (should) change it to
          
          C                   IF        %LEN(%trim(PINHIDDEN)) = 4 
          
          Tip: To find the lenght of the string in a char field, use TRIM first!
          Last edited by Marc_d; June 19, 2008, 01:46 AM.

          Comment


          • #6
            Re: Password Character

            Originally posted by Marc_d View Post
            We are all here to learn!

            I just retested my code and noticed that
            when the first PINNR of the PINCODE is zero, it fails.

            %char removes the first zero!

            Code:
            C                   IF        %LEN(%char(PINCODE)) = 4 
            
            you could (should) change it to
            
            C                   IF        %LEN(%trim(PINHIDDEN)) = 4 
            
            Tip: To find the lenght of the string in a char field, use TRIM first!
            instead of using %CHAR() use %EDITC(PINCODE:'X') that will retain the leading zeros
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Too much BIF's will kill you !

              I am coding to long to see :

              Code:
              C                   IF        %LEN(%trim(PINHIDDEN)) = 4 
              a better solution
              C                   IF        %LEN(%trim(PINHIDDEN)) = %len(PINHIDDEN)
              but ... easier to read
              C                   IF        PINHIDDEN = '****'

              Time for a cup of coffee !

              Code:
              PINCODE = numeric
              
              C                   IF        %LEN(%char(PINCODE)) = 4 
              
              instead of using %CHAR() 
              use %EDITC(PINCODE:'X') 
              that will retain the leading zeros
              In this case, with %EDITC(PINCODE:'X') it allways will be 4 !!!

              Comment

              Working...
              X