Author Topic: String translation  (Read 3997 times)

0 Members and 1 Guest are viewing this topic.

matrix2005in

  • Guest
String translation
« on: July 05, 2006, 02:38:41 PM »
hi

the code given below is translate  given string to another

(defun ceasar (txt /)
(vl-string-translate
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
"asdsdasdsdsadAKJHDFGKLJHDSFGKLHJDSSEFJK"
txt
)
)

(setq a
"can be anything that we dont know"
)


(DEFUN C:TET ()
(SETQ W (ceasar a))
(SETQ D (OPEN "C:\\TEST.TXT" "W"))
(SETQ AB (WRITE-LINE W D))
(CLOSE D)
)

(DEFUN C:TEP ()
(SETQ AG (OPEN "C:\\TEST.TXT" "R"))
(SETQ AH (READ-LINE AG))
(SETQ AS (ceasar AH)
(ALERT AS)
)

but this is not working....can any one help me??

thanks

mathew

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: String translation
« Reply #1 on: July 05, 2006, 03:05:03 PM »
What should the program do?

(defun ceasar (txt /)
  (vl-string-translate
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "asdsdasdsdsadAKJHDFGKLJHDSFGKLHJDSSEFJK"
    txt
  ) ;_  vl-string-translate
) ;_  defun
 
(DEFUN C:TET (A / AB D W)
  (SETQ W (ceasar a))
  (SETQ D (OPEN "C:\\TEST\\TEST.TXT" "W"));Replace the lengthy path
  (SETQ AB (WRITE-LINE W D))
  (CLOSE D)
)
(setq a "can be anything that we dont know")
(C:TET a)

(DEFUN C:TEP ( / AG AH AS)
  (SETQ AG (OPEN "C:\\TEST\\TEST.TXT" "R"));Replace the lengthy path
  (SETQ AH (READ-LINE AG))
  (CLOSE AG)
  (SETQ AS (ceasar AH))
  (ALERT AS)
)

Serge J. Gianolla

  • Guest
Re: String translation
« Reply #2 on: July 05, 2006, 08:41:00 PM »
This was the code given to you by Bruno Toniutti, and I think it'd be nice to make a reference here, anyway he gave you the answer later on too:
>the encryption is working good but decryption wont..

you must use a rotation of 13 positions (a  (position 1) becomes (1 + 13) =
n  etc.) for an alphabet of 26 characters. Thus this algo works to encrypt
and decrypt.

Bruno Toniutti
(sorry for my english level)

Code: [Select]
(defun ceasar (txt /)
  (vl-string-translate
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
    txt
  )
)

Hi Evgeniy,
matrix2005in is none other than Mathew2006 you answere to in autodesk ng! - I know this thanks to LE :-)

matrix2005in

  • Guest
Re: String translation
« Reply #3 on: July 05, 2006, 10:49:20 PM »
hi

yeah if you see i signing off with my name = "mathew" in both places
there is no catch in that..and another quetion "string stripping" i asked in both places and i got same people answerd...

mathew

Serge J. Gianolla

  • Guest
Re: String translation
« Reply #4 on: July 05, 2006, 10:59:04 PM »
hi

yeah if you see i signing off with my name = "mathew" in both places
there is no catch in that..
mathew

Really! I must have misunderstood your answer then: http://www.theswamp.org/index.php?topic=10378.msg132250#msg132250
 :wink:

matrix2005in

  • Guest
Re: String translation
« Reply #5 on: July 05, 2006, 11:11:35 PM »
hi Evgeniy

the same problem... the code is not decrypting or translating to its original form... :-(


matrix2005in

  • Guest
Re: String translation
« Reply #6 on: July 05, 2006, 11:13:37 PM »
HA HA

my partner done that while i was not on my desk........ :-D

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: String translation
« Reply #7 on: July 06, 2006, 02:53:59 AM »
you must use a rotation of 13 positions (a  (position 1) becomes (1 + 13) =
n  etc.) for an alphabet of 26 characters. Thus this algo works to encrypt
and decrypt.

Bruno Toniutti

Not necessarily...  :-)

Code: [Select]
(defun ceasar (txt /)
  (vl-string-translate
    " aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
    "ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa "
    txt
  ) ;_  vl-string-translate
) ;_  defun

; Test:
(setq str "can be anything that we dont know")
(setq crypt-str(ceasar a)) ; ->> "xzmZyvZzmbgsrmtZgszgZdvZwlmgZpmld"
(ceasar crypt-str) ; ->> "can be anything that we dont know"

matrix2005in

  • Guest
Re: String translation
« Reply #8 on: July 06, 2006, 09:41:15 AM »
Yeah this code will work...my question is...

CRITERIA ONE

A) ENCRYPT/TRANSLATE SOME STRING USING THE SAME FUNCTION AND SAVE IN A TEXT FILE.

B) CALL  ENCRYPTED TEXT FILE ,READ MESSAGE AND DECRYPT SAME.

CRITERIA TWO

A) ENCRYPT/TRANSLATE SOME STRING USING THE SAME FUNCTION AND SAVE  TEXT FILE IN ONE MACHINE.

B) DECRYPT THE CONTENT IN ANOTHER MACHINE WITH SAME FUNCTION
 

thanks

mathew

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: String translation
« Reply #9 on: July 06, 2006, 10:15:07 AM »
Yeah this code will work...my question is...

CRITERIA ONE

A) ENCRYPT/TRANSLATE SOME STRING USING THE SAME FUNCTION AND SAVE IN A TEXT FILE.

B) CALL  ENCRYPTED TEXT FILE ,READ MESSAGE AND DECRYPT SAME.

CRITERIA TWO

A) ENCRYPT/TRANSLATE SOME STRING USING THE SAME FUNCTION AND SAVE  TEXT FILE IN ONE MACHINE.

B) DECRYPT THE CONTENT IN ANOTHER MACHINE WITH SAME FUNCTION
 

thanks

mathew

I asked it two weeks ago!  :-(

matrix2005in

  • Guest
Re: String translation
« Reply #10 on: July 06, 2006, 10:41:40 AM »
oh :-)

OK then is there anyway to translate some word say my name "Mathew" to some other strings say "Fjgasj"  and decrypt back to the original  form...but that must be save in a text file and read/decrypt the same..

mathew

Andrea

  • Water Moccasin
  • Posts: 2372
Re: String translation
« Reply #11 on: July 06, 2006, 03:46:18 PM »
oh :-)

OK then is there anyway to translate some word say my name "Mathew" to some other strings say "Fjgasj"  and decrypt back to the original  form...but that must be save in a text file and read/decrypt the same..

mathew

take a look here... -> ;-)
Keep smile...

matrix2005in

  • Guest
Re: String translation
« Reply #12 on: July 18, 2006, 10:57:31 AM »
is there anyone to resolve this?? :roll: :-(

Andrea

  • Water Moccasin
  • Posts: 2372
Re: String translation
« Reply #13 on: July 21, 2006, 03:51:27 PM »
dont forget to close your file...

(DEFUN C:TEP ()
(SETQ AG (OPEN "C:\\TEST.TXT" "R"))
(SETQ AH (READ-LINE AG))
(SETQ AS (ceasar AH)
(CLOSE AG)
(ALERT AS)
(ALERT AH)

)
« Last Edit: July 21, 2006, 03:56:00 PM by Andrea »
Keep smile...