Jump to content

Passward


Dayananda

Recommended Posts

How to get the pass ward by lisp.

when entering the pass ward text shall not displayed. 

(setq passward (getstring '\nEnter the passward))

 

Edited by Dayananda
spelling corrected
Link to comment
Share on other sites

3 hours ago, Dayananda said:

How to get the pass ward by lisp.

when entering the pass ward text shall not displayed. 


(setq passward (getstrig '\nEnter the passward))

 

 

(getstring...) not (getstrig..)

  • Like 1
  • Funny 1
Link to comment
Share on other sites

2 hours ago, Tharwat said:

Then you need to use GRREAD function instead.

 

just quick written for testing, so no [<-- backspace] function 

(defun foo ($ n / l k str x)
;;hp:pword 16.04.2020
  (terpri)
  (princ (setq x t str "Password : "))
  (while (and x (setq k (grread nil)))
    (if	(and (= (car k) 2)
	     (numberp (setq x (cadr k )))
	     (< 33 x 127)
	     (< (length l) n)
	)
      (progn (princ (strcat "\r" (setq str (strcat str $))))
	     (setq l (cons x l))
      )
      (setq x nil)
    )
  )
  (vl-list->string (reverse l))
)

 

test

(defun c:test (/ pw)
  (if (= "Tharwat" (setq pw (foo "*" 7)))
    (alert pw)
    (alert "Sorry!! ask Donald Trump!!")
  )
  (princ)
)

 

Edited by hanhphuc
comment for [backspace]
  • Like 1
  • Funny 1
  • Thanks 1
Link to comment
Share on other sites

@hanhphuc nicely done. :)

 

Here is my attempt in this regard.

 

(defun c:pass (/ wrd fed str fst snd lst msg gr run)
  ;; Tharwat - 16.Apr.2020	;;
  (setq	wrd "AutoLISP"
	fed ""
	msg "\rEnter your password : "
  )
  (while (and (not run)
	      (princ (strcat msg fed))
	      (or (eq (car (setq gr (grread nil))) 5)
		  (member (setq fst (car gr)) '(2 3 25))
	      )
	      (numberp (setq snd (cadr gr))) 
	      (< 33 snd 127)                 
	 )

    (cond ((and (eq fst 2) (not (member snd '(13 32))))
	   (setq str (chr snd)
		 fed (strcat fed "*")
		 lst (cons str lst)
	   )
	  )
	  ((or (member fst '(3 25))
	       (member snd '(13 32))
	   )
	   (setq run t)
	  )
    )
  )
  (alert (if (= (apply 'strcat (reverse lst)) wrd)
	   "Well done."
	   "Bad input.Try again."
	 )
  )
  (princ)
)

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Perhaps something like this?

;; Get Password  -  Lee Mac
;; Prompts the user to enter a string whilst disguising the input
;; msg - [str] [Optional] Prompt string
;; Returns: [str] Input received from the user, else an empty string

(defun LM:getpassword ( msg / gr1 gr2 rtn )
    (setq msg (princ (cond (msg) ("\nEnter password: ")))
          rtn ""
    )
    (while
        (progn
            (setq gr1 (grread nil 10)
                  gr2 (cadr gr1)
                  gr1 (car  gr1)
            )
            (cond
                (   (= 2 gr1)
                    (cond
                        (   (< 31 gr2 127)
                            (setq rtn (strcat rtn (chr gr2)))
                            (princ "\225")
                        )
                        (   (= 13 gr2)
                            nil
                        )
                        (   (and (= 8 gr2) (< 0 (strlen rtn)))
                            (setq rtn (substr rtn 1 (1- (strlen rtn))))
                            (princ "\010 \010")
                        )
                        (   t   )
                    )
                )
                (   (= 25 gr1)
                    nil
                )
                (   t   )
            )
        )
    )
    rtn
)
(LM:getpassword nil)

 

Edited by Lee Mac
  • Like 1
Link to comment
Share on other sites

55 minutes ago, Jonathan Handojo said:

Probably "just because"... 🤣

😜

 

Found some old code for this ... maybe someone can use it even if the OP has a different requirement.

(defun _getpassword (msg / $value f fn fno id r)
  (if (and (setq fn (vl-filename-mktemp nil nil ".dcl")) (setq fno (open fn "w")))
    (progn
      (write-line
	(strcat
	  "VALIDATE : dialog { label = \"Enter Password\"; spacer;: text {label = \""
	  msg
	  "\";} : edit_box {key = \"key\"; width = 40; password_char = \"»\";}spacer;ok_cancel;}"
	)
	fno
      )
      (close fno)
      (setq id (load_dialog fn))
      (new_dialog "VALIDATE" id)
      (action_tile "key" "(setq r $value)")
      (setq f (start_dialog))
      (unload_dialog id)
      (vl-file-delete fn)
      (if (and r (= 1 f))
	r
	""
      )
    )
  )
)
(_getpassword "Hello World")

image.png.b8d0cc6811b549fd3c433af9f1068826.png

Edited by ronjonp
Link to comment
Share on other sites

On 4/16/2020 at 7:55 PM, ronjonp said:

Why?

This need to run with Mac. OS also.

Edited by Dayananda
Link to comment
Share on other sites

1 hour ago, Dayananda said:

This need to run with MC OS also.

Apparently you are working for one of the freelancer's websites and exploiting our generosity to fulfill your customer's needs with all these different requests.

  • Confused 1
Link to comment
Share on other sites

N

3 hours ago, Tharwat said:

Apparently you are working for one of the freelancer's websites and exploiting our generosity to fulfill your customer's needs with all these different requests.

No I have designed few lips programs for windows for my office. For activate those I used password with dialog boxes.For that also I wrote to this forum and got the idea. But now I am working in another office . Unfortunately  they are using Mac.OS.

So I had to convert  my previous programs to support with that Mac os. At this Covid-19 situation our jobs are at risk.That is why I trying to add password to my programs.

Link to comment
Share on other sites

Try this.

It is an old version.

(defun pass (/ sir init_par numar $$sir lgr $sir n)
  (prompt "\nPassword, please: ")
  (setq init_par (list 67 48 110 115 117 115) $$sir T) ;;->C0nsus (Czeronsus)
  (while $$sir
   (if (and (setq numar (grread nil 4 1))(= (car numar) 2))
    (cond
     ((and (/= (cadr numar) 8)(/= (cadr numar) 13))
      (setq sir (append sir (list (cadr numar))))
      (princ "*")
     ) ;I
     ((= (cadr numar) 8)
      (setq lgr (length sir) n 0 $sir nil)
      (if (> lgr 0)(write-char 8))
      (while (< n (- lgr 1))
       (setq $sir (append $sir (list (nth n sir))) n (1+ n))
      )
      (setq sir $sir)
     ) ;II
     (T (setq $$sir nil)) ;III
    )
   )
  )
  (if (equal init_par sir) T)
)

 

  • Thanks 1
Link to comment
Share on other sites

How long are you going to be working there a simple password is a time bomb that the lisp/fas stops working, unless you have smart people it can be as simple as using "setenv". Then count down number of tries or check date. If you have your own web server can read a license file so could be as simple as 1 line "OK" 99.99 % of people have no idea how to get around software has stopped working.

 

(if (= (setq alancnt (getenv "xxxx")) nil)
(progn 
(setenv "xxxx" "0")
(alert "Your trial has started\n \n You have 50 times that you can use the software\n \n Contact Email  info@alanh.com.au\n \n for further information.")
)
(progn
(setq alancount (+ (atoi alancnt) 1))
(setenv "xxxx" (rtos alancount 2 0))
(alert (strcat "You have " (rtos (- 50 alancount) 2 0) " repeat to go"))
)
)

(if (>= alancount 50)
(progn
(alert "Your trial number has finished \n \n You need to contact\n \n Alanh Consulting \n \n Email  info@alanh.com.au")
(exit)
)
)

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, BIGAL said:

How long are you going to be working there a simple password is a time bomb that the lisp/fas stops working, unless you have smart people it can be as simple as using "setenv". Then count down number of tries or check date. If you have your own web server can read a license file so could be as simple as 1 line "OK" 99.99 % of people have no idea how to get around software has stopped working.

 


(if (= (setq alancnt (getenv "xxxx")) nil)
(progn 
(setenv "xxxx" "0")
(alert "Your trial has started\n \n You have 50 times that you can use the software\n \n Contact Email  info@alanh.com.au\n \n for further information.")
)
(progn
(setq alancount (+ (atoi alancnt) 1))
(setenv "xxxx" (rtos alancount 2 0))
(alert (strcat "You have " (rtos (- 50 alancount) 2 0) " repeat to go"))
)
)

(if (>= alancount 50)
(progn
(alert "Your trial number has finished \n \n You need to contact\n \n Alanh Consulting \n \n Email  info@alanh.com.au")
(exit)
)
)

 

 

Wow, I never know AutoCAD can do this! That's amazing stuff!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...