| View previous topic :: View next topic |
| Author |
Message |
sKy Op

Joined: 14 Apr 2005 Posts: 194 Location: Germany
|
Posted: Thu Jun 28, 2007 10:27 am Post subject: string encryption without eggdrop tcl commands? |
|
|
I am about to write my encrypted dcc chat. Dcc chat from tclsh to eggdrop is kinda easy with socket.
Eggdrop has the decrypt and encrypt command, very easy to use. But tclsh doesn`t has this command since it`s not an eggdrop.
Can you advise me a premade script with secure encryption? _________________ socketapi | Code less, create more. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Jun 28, 2007 10:37 am Post subject: |
|
|
The encryption used by eggdrop is in most cases based on the blowfish algorith. Unfortunately, this is a somewhat calculation-heavy encryption, making implementation in pure tcl "sluggish". I would therefore recommend implementing it as a loadable module to gain some performance.
That said, a nice site on the blowfish algorithm (with several examples in different languages) can be found here.
As for your request for premade scripts, unfortunately I can't think of any at this moment. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
|
| Back to top |
|
 |
sKy Op

Joined: 14 Apr 2005 Posts: 194 Location: Germany
|
Posted: Thu Jun 28, 2007 6:00 pm Post subject: |
|
|
I simple want to encrypt a plaintext with a password, send it over an unsecure connection and decrypt it with the same key on the other point.
http://tcllib.sourceforge.net/doc/aes.html looks fine and is currently known as secure. The example on the page isn`t enough for me, I need an example for decrypt aswell.
Would be cool if someone who understand that could write an example de- and encrypt. _________________ socketapi | Code less, create more. |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Fri Jun 29, 2007 10:20 am Post subject: |
|
|
It would be the same as the encrypt and decrypt command:
| Code: | set key "my_key"
set data "some data here to encrypt"
set encrypted [aes::encrypt $key $data]
set decrypted [aes::decrypt $key $encrypted] |
or
| Code: | set key "my_key"
set data "some data blah blib"
set encrypted [aes::aes -mode cbc -dir encrypt -key $key $data]
set decrypted [aes::aes -mode cbc -dir decrypt -key $key $encrypted] |
Thats how i have used it in the past, hope this helps. _________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
sKy Op

Joined: 14 Apr 2005 Posts: 194 Location: Germany
|
Posted: Sat Jun 30, 2007 3:35 am Post subject: |
|
|
Tosser^^, I used your example. But got an error "invalid key size "48": must be one of 128, 192 or 256". _________________ socketapi | Code less, create more. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Jun 30, 2007 3:52 am Post subject: |
|
|
"my_key" = 6 bytes (8 bits per byte) = 48 bits.
128 bits = 16 bytes, 192 bits = 24 bytes, 256 bits = 32 bytes |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Jun 30, 2007 7:33 am Post subject: |
|
|
Worth mentioning is that each character equals 1 byte. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
sKy Op

Joined: 14 Apr 2005 Posts: 194 Location: Germany
|
Posted: Sun Jul 01, 2007 6:51 pm Post subject: |
|
|
I still don`t get how this is supposed to work.
| Code: | proc test { } {
package require aes
set sixteen_bytes_key_data "1234567890123456"
set sixteen_byte_iv "1234567890123456"
set Key [aes::Init cbc $sixteen_bytes_key_data $sixteen_byte_iv]
set plaintext "1234567890123456"
set ciphertext [aes::Encrypt $Key $plaintext]
puts "ciphertext: $ciphertext"
set decr [aes::Decrypt $Key $ciphertext]
puts "decr: $decr"
aes::Final $Key
} |
_________________ socketapi | Code less, create more. |
|
| Back to top |
|
 |
|