Author Topic: lisp code scrambling  (Read 1806 times)

0 Members and 1 Guest are viewing this topic.

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
lisp code scrambling
« on: January 14, 2010, 12:45:41 PM »
inspired by EvgeniyElpanov
originally Kelvinator was introduced by someone called Kelvin R. Throop.
trying to avoid copyright problems i named mine VovKaFicator :)
scrambles localized variables and functions
strings and quoted lists remain intact
Code: [Select]
(defun VovKaFicator (Func UsedVars)
  (or GenVarName
      (defun GenVarName (VarName UsedVars /)
(if (assoc VarName UsedVars)
 UsedVars
 (cons (cons VarName (read (substr (vl-filename-mktemp "_" "\\") 2))) UsedVars)
)
      )
  )
  (cond ((null Func) nil)
((= (car Func) 'QUOTE) Func)
((listp (car Func))
(cons (VovKaFicator (car Func) UsedVars) (VovKaFicator (cdr Func) UsedVars))
)
((= (car Func) 'DEFUN)
(cons (car Func)
      (cons (cond ((cdr (assoc (cadr Func) UsedVars)))
  ((cadr Func))
    )
    (VovKaFicator (cddr Func)
  (progn (foreach v (vl-remove '/ (caddr Func))
   (setq UsedVars (GenVarName v UsedVars))
 )
 UsedVars
  )
    )
      )
)
)
((= (car Func) 'LAMBDA)
(foreach v (vl-remove '/ (cadr Func)) (setq UsedVars (GenVarName v UsedVars)))
(cons (car Func) (VovKaFicator (cdr Func) UsedVars))
)
((assoc (car Func) UsedVars)
(cons (cdr (assoc (car Func) UsedVars)) (VovKaFicator (cdr Func) UsedVars))
)
(t (cons (car Func) (VovKaFicator (cdr Func) UsedVars)))
  )
)
(setq
  testfunc (quote (defun test (arg1 DoNotRename / var1 var2 var3 test *error*)
   (defun *error* (msg) (princ msg))
   (defun test (arg3) arg3)
   (setq var1 (strcat arg1 (setq var2 (strcat DoNotRename "_" arg1))))
   (setq
     var3 (strcat (vl-princ-to-string
    (mapcar (function (lambda (e) (test e))) '(1 var1 3))
  )
  var1
  ((lambda (str1 / str2 var1)
     (setq str2 (strcat arg1 (setq var1 DoNotRename)))
     (strcat str1 str2 var2)
   )
    var1
  )
  var2
  )
   )
 )
  )
)
(prin1
  (VovKaFicator testfunc
'((*ERROR* . *ERROR*) (var3 . guesswhat) (DoNotRename . DoNotRename))
  )
)
GenVarName is a subject to change to strengthen the ambiguities  :roll:

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: lisp code scrambling
« Reply #1 on: January 14, 2010, 01:20:18 PM »
How to use your function?
I have not understood, how it to use...

>> add:

Apologize, has understood, an example in the end...
« Last Edit: January 14, 2010, 01:30:38 PM by ElpanovEvgeniy »

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: lisp code scrambling
« Reply #2 on: January 14, 2010, 02:54:24 PM »
Recursive... much...  :evil:

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: lisp code scrambling
« Reply #3 on: January 15, 2010, 04:08:46 AM »
Recursive... much...  :evil:
sorry, this was the only way i could do it  :wink: