This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

string encryption without eggdrop tcl commands?

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

string encryption without eggdrop tcl commands?

Post by sKy »

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.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Can't you use something from tcllib like yencode of uuencode?

http://tcllib.sourceforge.net/doc/index.html
r0t3n @ #r0t3n @ Quakenet
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

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.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

It would be the same as the encrypt and decrypt command:

Code: Select all

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: Select all

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
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

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.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

"my_key" = 6 bytes (8 bits per byte) = 48 bits.

128 bits = 16 bytes, 192 bits = 24 bytes, 256 bits = 32 bytes
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Worth mentioning is that each character equals 1 byte.
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

I still don`t get how this is supposed to work.

Code: Select all

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.
Post Reply