Author Topic: (Challenge) Encrypt and decipher the text.  (Read 11193 times)

0 Members and 1 Guest are viewing this topic.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
(Challenge) Encrypt and decipher the text.
« on: September 14, 2010, 03:38:16 AM »
In this topic, I propose to compete in the encryption and decryption of text. You can use any algorithms, but there is one condition, you must create a program for encryption and decryption. The text after decryption should just repeat the original.

Code: [Select]
(setq s "(alert \"Hello, world!\")")

(encrypt s) =>> incomprehensible information (text, numbers, lists ...)

(decrypt(encrypt s)) =>> "(alert \"Hello, world!\")"
« Last Edit: September 14, 2010, 04:23:32 AM by ElpanovEvgeniy »

Patrick_35

  • Guest
Re: (Challenge) Encrypt and decipher the text.
« Reply #1 on: September 14, 2010, 04:29:41 AM »
A subroutine which dates back to version 14.
Always topical  8-)

Code: [Select]
(decrypt (encrypt "long life theswamps"))
@+

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) Encrypt and decipher the text.
« Reply #2 on: September 14, 2010, 04:45:34 AM »
Explain why the code after compilation?
You can not show the algorithm?
In this topic, I propose to share ideas and algorithms, to learn from friends ...

Patrick_35

  • Guest
Re: (Challenge) Encrypt and decipher the text.
« Reply #3 on: September 14, 2010, 05:04:10 AM »
Explain why the code after compilation?
You can not show the algorithm?
In this topic, I propose to share ideas and algorithms, to learn from friends ...
As this is to encrypt / decrypt a code, I voluntarily compiled lisp (which is very rare for me).

Now, I am willing to distribute the code, but in private, because if I do a broadcast, it is nothing more to encode anything

You can also try to break the code

@+

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: (Challenge) Encrypt and decipher the text.
« Reply #4 on: September 14, 2010, 05:14:12 AM »
How about this:

Code: [Select]
(defun NumCryptWithKey (numLst numKey operand / useKey)
  (setq useKey numKey)
  (mapcar
    '(lambda (a / b)
      (setq b (car useKey))
      (setq useKey (cond ((cdr useKey)) (numKey)))
      (operand a b)
    )
    numLst
  )
)

(defun Encrypt (str)
  (NumCryptWithKey (vl-string->list str) '(8 5 13 12 99 3) +)
)

(defun Decrypt (numLst)
  (vl-list->string (NumCryptWithKey numLst '(8 5 13 12 99 3) -))
)

; (Encrypt "(alert \"Hello, world!\")") => (48 102 121 113 213 119 40 39 85 113 207 111 119 49 45 131 210 117 116 105 46 46 140)
; (Decrypt (Encrypt "(alert \"Hello, world!\")")) => "(alert \"Hello, world!\")"

While working on this I stumbled on something strange:
(ascii "ƒ") =>  131
(vl-string->list "ƒ") => (402)
Is this a bug in Bricscad?

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) Encrypt and decipher the text.
« Reply #5 on: September 14, 2010, 05:17:06 AM »
While working on this I stumbled on something strange:
(ascii "ƒ") =>  131
(vl-string->list "ƒ") => (402)
Is this a bug in Bricscad?

AutoCAD 2011:
(ascii "?") =>  63
(vl-string->list "?") => (63)

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) Encrypt and decipher the text.
« Reply #6 on: September 14, 2010, 05:21:53 AM »
How about this:

Code: [Select]
(defun NumCryptWithKey (numLst numKey operand / useKey)
  (setq useKey numKey)
  (mapcar
    '(lambda (a / b)
      (setq b (car useKey))
      (setq useKey (cond ((cdr useKey)) (numKey)))
      (operand a b)
    )
    numLst
  )
)

(defun Encrypt (str)
  (NumCryptWithKey (vl-string->list str) '(8 5 13 12 99 3) +)
)

(defun Decrypt (numLst)
  (vl-list->string (NumCryptWithKey numLst '(8 5 13 12 99 3) -))
)

; (Encrypt "(alert \"Hello, world!\")") => (48 102 121 113 213 119 40 39 85 113 207 111 119 49 45 131 210 117 116 105 46 46 140)
; (Decrypt (Encrypt "(alert \"Hello, world!\")")) => "(alert \"Hello, world!\")"


Good idea, the program uses the key, you can use different keys for different purposes...

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) Encrypt and decipher the text.
« Reply #7 on: September 14, 2010, 05:24:39 AM »
As this is to encrypt / decrypt a code, I voluntarily compiled lisp (which is very rare for me).

Now, I am willing to distribute the code, but in private, because if I do a broadcast, it is nothing more to encode anything

You can also try to break the code

@+

I appreciate your code and your protection!
For fun, I propose to write new code, just for this topic ...

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: (Challenge) Encrypt and decipher the text.
« Reply #8 on: September 14, 2010, 05:30:11 AM »
AutoCAD 2011:
(ascii "?") =>  63
(vl-string->list "?") => (63)
What do you get with this:
(chr 131) => "ƒ"

Patrick_35

  • Guest
Re: (Challenge) Encrypt and decipher the text.
« Reply #9 on: September 14, 2010, 05:31:20 AM »
Ok

A simple

Code: [Select]
(defun encrypt(txt)
  (vl-list->string (mapcar '(lambda(x) (boole 6 x 13)) (vl-string->list txt)))
)

(encrypt (encrypt "long life theswamps"))

@+

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: (Challenge) Encrypt and decipher the text.
« Reply #10 on: September 14, 2010, 05:32:30 AM »
AutoCAD 2011:
(ascii "?") =>  63
(vl-string->list "?") => (63)
What do you get with this:
(chr 131) => "ƒ"

(chr 131) => "ƒ"

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: (Challenge) Encrypt and decipher the text.
« Reply #12 on: September 14, 2010, 05:59:26 AM »
How about this:
< snip>


nice functionality Roy.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE3

  • Guest
Re: (Challenge) Encrypt and decipher the text.
« Reply #13 on: September 14, 2010, 10:41:20 AM »
Something I wrote 17 years ago.... geezzzz you guys are old!  :laugh:

http://www.theswamp.org/index.php?topic=9441.msg121482#msg121482

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: (Challenge) Encrypt and decipher the text.
« Reply #14 on: September 14, 2010, 10:45:17 AM »
Wish I had time for more posting than just the concept... it was intended for use with LSP files, so there was no need to handle extended ASCII characters.  I made a simple substitution cypher (including line breaks) called "NCRYPT", then re-sequenced the output so each line had a fixed number of characters.  The file also included an header with decryption instructions, including the proper decryption cypher file, the option for a kill date, permissible user names, and permissible computer names.  The decryption routine "DCRYPT" made use of a separate file with the decryption substitution matrix itself encoded and fixed-line lengths.  The one module I did prototype was for a straight to-file function, while I outlined another for decrypting to a temp file including a (load...) call, and another that would have the encrypted file as self-contained with the decryption matrix included in the header.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}