2

I'm using DES in TCL to encrypt some phrases and I want to store those encrypted phrases in some ascii files which I need to manipulate easily. Therefore, I would like the "encrypted phrase" to be constituted only of standard ascii characters (preferentially with no spaces).

I'm using something like this to ecrypt:

set encrypted [ DES:des -dir encrypt -key "abcdefgh" "This_phrase" ]

I would like "encrypted" to be a standard ascii code, not something that, as it happens, may even brake my terminal if displayed.

Thank you very much. Leandro.

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
leandro
  • 175
  • 8

1 Answers1

5

You could either replace all characters that might have a special meaning (everything except a-zA-Z0-9 etc) or encode it with e.g. base64.

set encrypted [base64::encode -wrapchar {} [DES:des -dir encrypt -key abcdefgh "This_phrase"]]

You need to strip the extra layer (base64, escape sequence encoding or whatever you used to convert the binary data to ascii) if you want to decode it.

Johannes Kuhn
  • 14,778
  • 4
  • 49
  • 73