tkcrypt
changeset 2 063a30048b60
parent 1 f68e1244a263
child 3 533cbe2b7f3c
--- a/tkcrypt	Wed Nov 01 17:02:47 2006 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-#!/usr/bin/wish
-
-text .text -relief sunken -bd 2 -yscrollcommand ".scroll set" -setgrid 1 \
-	-height 30 -undo 1 -autosep 1
-scrollbar .scroll -command ".text yview"
-pack .scroll -side right -fill y
-pack .text -expand yes -fill both
-
-menu .menu -tearoff 0
-
-set File .menu.file
-menu $File -tearoff 0
-.menu add cascade -label "File" -menu $File
-$File add command -label "New" -command { newfile }
-$File add command -label "Open" -command { openfile }
-$File add command -label "Save" -command { savefile $actualfile $actualpass}
-$File add command -label "Save as..." -command { savefile }
-$File add separator
-$File add command -label "Quit" -command { exit}
-
-. configure -menu .menu
-
-set actualpass ""
-set actualfile ""
-wm title . "tkcrypt - New File"
-
-proc askpassword { op entries } {
-	set tl [toplevel .pass]
-	global password1 password2
-	global actualpass
-
-	set password1 ""
-	set password2 ""
-	label .pass.info -text "Please introduce your password two times for $op:"
-	pack .pass.info -side top
-
-	entry .pass.entry -textvariable password1 -show "*"
-	pack .pass.entry -side top
-	if { $entries == 2} {
-		entry .pass.entry2 -textvariable password2 -show "*"
-		pack .pass.entry2 -side top
-	}
-	button .pass.ok -text "Ok" -command \
-		{ destroy .pass }
-	pack .pass.ok -side left
-	button .pass.cancel -text "Cancel" \
-		-command {set password1 ""; set password2 ""; destroy .pass}
-	pack .pass.cancel -side right
-
-	bind .pass.entry <Return> {destroy .pass}
-	bind .pass.entry <Escape> {set password1 ""; set password2 ""; destroy .pass}
-
-	focus $tl
-	focus $tl.entry
-	grab $tl
-	tkwait window $tl
-	catch { grab release $tl }
-	focus .
-
-	if { $entries != 2 } {
-		set tmppass $password1
-		set password1 ""
-		return $tmppass
-	}
-
-	if { $password1 == $password2 } {
-		set tmppass $password1
-		set password1 ""
-		set password2 ""
-		return $tmppass
-	} else {
-		set password1 ""
-		set password2 ""
-		tk_messageBox -type ok -message "The passwords don't match" \
-			-icon error
-		return ""
-	}
-}
-
-proc newfile { } {
-	global actualpass actualfile
-	set actualpass ""
-	set actualfile ""
-	wm title . "tkcrypt - New File"
-}
-
-proc openfile { } {
-	global env actualpass actualfile
-	set file [tk_getOpenFile]
-	set pass [askpassword "Open" 1]
-
-	if { $pass == "" } { return }
-
-	# Decode
-	set env(PASS) $pass
-
-	set error [ catch { set txt [exec ccrypt -dc -E PASS $file] } result ]
-	if { $error != 0 } {
-		tk_messageBox -type ok -message "Password incorrect:\n$result" \
-			-icon error
-		return
-	}
-
-	.text delete 1.0 end
-	.text insert end $txt
-#	while { [eof $fd ] != 1 } {
-#		set line [gets $fd]
-#		.text insert end $line
-#	}
-
-	set env(PASS) ""
-
-	set actualpass $pass
-	set actualfile $file
-	wm title . "tkcrypt - $file"
-}
-
-proc savefile { {file ""} {pass ""} } {
-	global env actualpass actualfile
-
-	if { $file == "" } {
-		set file [tk_getSaveFile]
-	}
-
-	if { $pass == "" } {
-		set pass [askpassword "Save" 2]
-
-		if { $pass == "" } { return }
-	}
-
-	# Decode
-	set env(PASS) $pass
-
-	set error [ catch { set fd [open "|ccrypt -E PASS >$file" w] } result ]
-	if { $error != 0 } {
-		tk_messageBox -type ok -message "Password incorrect:\n$result" \
-			-icon error
-		return
-	}
-
-	puts -nonewline $fd [.text get 1.0 end]
-	close $fd
-
-	set env(PASS) ""
-	set actualfile $file
-	wm title . "tkcrypt - $file"
-	tk_messageBox -type ok -message "File \"$file\" saved!" \
-			-icon info
-}