Dayananda Posted April 16, 2020 Posted April 16, 2020 (edited) How to get the pass ward by lisp. when entering the pass ward text shall not displayed. (setq passward (getstring '\nEnter the passward)) Edited April 16, 2020 by Dayananda spelling corrected Quote
ronjonp Posted April 16, 2020 Posted April 16, 2020 20 minutes 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)) https://www.afralisp.net/archive/lispa/lisp48h.htm 1 Quote
Dayananda Posted April 16, 2020 Author Posted April 16, 2020 I need it feed directly without dialog box. Quote
dlanorh Posted April 16, 2020 Posted April 16, 2020 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..) 1 1 Quote
1958 Posted April 16, 2020 Posted April 16, 2020 (setq passward (getstring t "Enter the passward ")) Quote
Tharwat Posted April 16, 2020 Posted April 16, 2020 1 hour ago, Dayananda said: I need it feed directly without dialog box. Then you need to use GRREAD function instead. 1 1 Quote
hanhphuc Posted April 16, 2020 Posted April 16, 2020 (edited) 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 April 16, 2020 by hanhphuc comment for [backspace] 1 1 1 Quote
Tharwat Posted April 16, 2020 Posted April 16, 2020 @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) ) 1 1 Quote
Lee Mac Posted April 16, 2020 Posted April 16, 2020 (edited) 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 April 16, 2020 by Lee Mac 1 Quote
ronjonp Posted April 16, 2020 Posted April 16, 2020 6 hours ago, Dayananda said: I need it feed directly without dialog box. Why? Quote
Jonathan Handojo Posted April 16, 2020 Posted April 16, 2020 16 minutes ago, ronjonp said: Why? Probably "just because"... Quote
ronjonp Posted April 16, 2020 Posted April 16, 2020 (edited) 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") Edited April 16, 2020 by ronjonp Quote
Dayananda Posted April 18, 2020 Author Posted April 18, 2020 (edited) On 4/16/2020 at 7:55 PM, ronjonp said: Why? This need to run with Mac. OS also. Edited April 18, 2020 by Dayananda Quote
ronjonp Posted April 18, 2020 Posted April 18, 2020 7 minutes ago, Dayananda said: This need to run with MC OS also. Quote
Tharwat Posted April 18, 2020 Posted April 18, 2020 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. 1 Quote
Dayananda Posted April 18, 2020 Author Posted April 18, 2020 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. Quote
lido Posted April 18, 2020 Posted April 18, 2020 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) ) 1 Quote
BIGAL Posted April 18, 2020 Posted April 18, 2020 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) ) ) 1 1 Quote
Jonathan Handojo Posted April 19, 2020 Posted April 19, 2020 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! Quote
Recommended Posts
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.