Jump to content

encrypt / decrypt files using lsp


DGRL

Recommended Posts

Coders

 

Does any of you know if it is possible encrypt txt files?

I have some output data written to a txt file using lsp but that is sensitive and i want it to be encrypted and decrypted when the lsp is needing the info again?

Link to comment
Share on other sites

And how to de-compile to read the file again?

Or set it as variable and load that back in

 

You don't "decompile". You have source code that you compile. :unsure:

Link to comment
Share on other sites

i wasn't talking about LSP files but txt or other file types lol

And fas cant be read by lsp using the read-line funtion as far as i know

Link to comment
Share on other sites

How secure do you want the file to be?

 

You could do something very simple that makes it a pain to read, for example at the start of the file list an encryption key, perhaps 7 double digit numbers (65 03 14 etc) then simple go through the text file shifting each character by the next number in the key, either add or subtraction as well. Simple to work out and code I guess.

 

Similarly to hav it password protected you could do similar with the passwird being the key

Link to comment
Share on other sites

Here is basic idea if OP means encrypt/decrypt text file, ie: ascii

;simple XOR cipher - hanhphuc
;reference https://en.wikipedia.org/wiki/XOR_cipher

(defun [color="blue"]xor[/color] (str i) (vl-list->string (mapcar ''((x) (boole 6 i x)) (vl-string->list str))))

;Test= "11110011" = 243 (ascii)
_$ (setq str (xor "Hanhphuc" 243 )) [color="red"]; encypt [/color]
[color="green"]"»’›ƒ›†"[/color]
_$ (xor str 243)[color="red"]; decrypt[/color]
[color="green"]"Hanhphuc"[/color]

 

;Example from wiki

"W"; 87
"i"; 105
"k"; 107
"i"; 105

;example; [color="red"][b]W[/b][/color]iki
(ascii (xor "[color="red"]W[/color]" 243) )
; 164

;(chr "W") = 87
;"11110011" = 243
_$ ([color="blue"]menucmd[/color] "M=$([color="blue"]xor[/color], 87, 243)")
; 164

;Decrypt

(xor "‡»¶ó¢¦º°¸ó±¡¼¤½óµ¼«ó¹¦¾£*󼥶¡ó§»¶ó¿²©ªó·¼´" 211)
(xor "Š¶»þ¯«·½µþ¼¬±©°þ¸±¦þ´«³®*þ±¨»¬þª¶»þ²¿¤§þº±¹"  222)
(xor "½ŒÉ˜œ€Š‚É‹›†ž‡É†‘Ƀœ„™šÉ†ŸŒ›ÉŒÉ…ˆ“É†Ž" 233)

"The quick brown fox jumps over the lazy dog"

Edited by hanhphuc
Link to comment
Share on other sites

i wasn't talking about LSP files but txt or other file types lol

And fas cant be read by lsp using the read-line funtion as far as i know

 

There are a few examples HERE for en\decrypting.

Link to comment
Share on other sites

  • 3 months later...

I have an autolisp file:

(defun c:test ()

(vl-registry-read "HKEY_CURRENT_USER\\Software\\Microsoft\\pass")

("HKEY_CURRENT_USER\\Software\\Microsoft\\pass" "" "abcq123")

)

(setq Password "HKEY_CURRENT_USER\\Software\\Microsoft\\pass")

 

(setq password (123456789abc)

password2 (987654321cba)

(setq password password2 )

(setq 1 9)

(setq 2 8)

(setq 3 7)

(setq 4 6)

(setq 5 5)

(setq 7 3)

(setq 8 2)

(setq 9 1)

(setq a c)

(setq b a)

(setq c b)

(if (= Password "abc123") (equal password password2 ) fuzz)

)

)

 

please help

I want the password to be equal to passwor2 to run lisp

Link to comment
Share on other sites

not sure i understand, try assoc list

[color="green"];vanilla[/color]
(defun foo (str)
 (apply 'strcat
 (mapcar ''((x)
	    (cond
	     ((cdr
	       ([color="blue"]assoc[/color]
		(chr x)
		'([color="purple"]("1" . "9")
		  ("2" . "8")
		  ("3" . "7")
		  ("4" . "6")
		  ("5" . "5")
		  ("6" . "4")
		  ("7" . "3")
		  ("8" . "2")
		  ("9" . "1")
		  ("10" . "0")
		  ("a" . "c")
		  ("b" . "b")
		  ("c" . "a")[/color]
		  )
		)
	       )
	      )
	     ("?")
	     )
	    )
	 (vl-string->list str)
	 )
 )
 )

(foo [color="purple"]"123abc"[/color])
[color="green"]"987cba"[/color] ?

[color="green"];Vlisp[/color]
([color="blue"]vl-string-translate [/color][color="purple"]"1234567890abc" "9876543210cba"[/color] [color="red"][b]"123abc"[/b][/color])
[color="green"]"987cba"[/color] ?

Edited by hanhphuc
add vlisp version
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...