File Cipher — File Browser
FileCipherv1.0 / FileCipherv1.0 / crypt.mrc
crypt.mrc — 13.05 KB — Download this file
;mIRC File Encryper by danielson of Dalnet
;Copyright ©1998 All Rights Reserved
;Please ask me before using this in your script, if you ask
;I will unless some weird circumstances I will let you.
;Program uses a password based Algorithm
;For files over around 12kb please use UltraFast, but you don't have too.
;Thankyou, Copyright © Brad Basler 1998 (All Rights Reserved)
;Use /cryptwindow to start it
-- Listens for mouse commands on @menu --
menu @menu {
sclick: {
if $inrect($mouse.x,$mouse.y,2,2,60,6) == $true { /set %mode Normal | /changestatus Encryption mode set to normal. | /close -@ @menu | /halt }
if $inrect($mouse.x,$mouse.y,2,14,21,8) == $true { /set %mode Fast | /changestatus Encryption mode set to Fast. | /close -@ @menu | /halt }
if $inrect($mouse.x,$Mouse.y,2,26,67,8) == $true { /set %mode Ufast | /changestatus Mode set to Ultrafast. | /close -@ @Menu | /halt }
else { /changestatus Encryption mode not selected. | /close -@ @menu | /halt }
}
}
-- Listens for mouse commands on @Crypt --
menu @Crypt {
mouse {
if $inrect($mouse.x,$mouse.y,207,43,41,15) == $true {
if %last != 4 {
set %last 4
/hiliteCompare
}
/halt
}
if $inrect($Mouse.x,$mouse.y,27,43,54,15) == $true {
if %last != 1 {
/set %last 1
/hiliteChoose
}
/halt
}
else if $inrect($mouse.x,$mouse.y,97,43,37,15) == $true {
if %last != 2 {
set %last 2
/hiliteEncrypt
}
}
else if $inrect($mouse.x,$mouse.y,153,43,37,15) == $true {
if %last != 3 {
set %last 3
/hiliteDecrypt
}
}
else if %Last != $null {
/hilite
/drawrect @Crypt
/unset %last
/halt
}
}
dclick: {
if %last == $null {
if $window(@menu).state != $null { close -@ @menu | /halt }
/window -hp +f @menu $mouse.x $mouse.y 80 46
/drawrect -nf @Menu 1 1 0 0 80 46
/drawtext -n @Menu 8 Arial 12 2 2 Normal Cipher
/drawtext -n @Menu 8 Arial 12 2 14 Fast Cipher
/drawtext -n @Menu 8 Arial 12 2 26 UltiaFast Cipher
/drawtext @Menu
/window -ar @menu
}
}
sclick: {
if $window(@menu).state != $null { /close -@ @menu | /window -ar @Crypt | /halt }
if %last == 1 && $inrect($Mouse.x,$mouse.y,27,43,54,15) == $true { /sfile | /unset %last }
else if %last == 2 && $inrect($mouse.x,$mouse.y,97,43,37,15) == $true {
if %file == $null { /beep | /changestatus Error: need a file selected, use Choose file | /halt }
if %mode == $null { /beep | /changestatus Error: Encryption mode not selected, click the mouse. | /halt }
if $editbox(@Crypt) == $null { /beep | /changestatus Error: need a password | /halt }
if $len($editbox(@Crypt)) > 10 { /beep | /changestatus Error: password max length is 10 characters | /halt }
/EncryptFile $editbox(@Crypt)
}
else if %last == 3 && $inrect($mouse.x,$mouse.y,153,43,37,15) == $true {
if %file == $null { /beep | /changestatus Error: need a file selected, use Choose file | /halt }
if %mode == $null { /beep | /changestatus Error: Encryption mode not selected, click the mouse. | /halt }
if $editbox(@Crypt) == $null { /beep | /changestatus Error: need a password | /halt }
if $len($editbox(@Crypt)) > 10 { /beep | /changestatus Error: password max length is 10 characters | /halt }
/DecryptFile $editbox(@Crypt)
}
else if %last == 4 && $inrect($mouse.x,$mouse.y,207,43,41,15) == $true {
if %mode == Ufast { /beep | /changestatus Compare not yet available for Ultrafast mode. | /halt }
if %mode == Fast { /beep | /changestatus Compare not yet available for fast mode. | /halt }
if %mode == $Null { /beep | /changestatus Error: need a file selected, use Choose file | /halt }
set %file1 $dir="Encoded File"
if %file1 == $null { /beep | /changestatus Error: need an Encoded file.. | /halt }
set %file2 $dir="Original File"
if %file2 == $null { /beep | /changestatus Error: need an Encoded file.. | /halt }
/comparefiles %file1 %file2
}
}
}
-- Aliases Section of crypt.mrc [mIRC File Encrypter] --
alias sopen {
/set %ispname $1
/sockopen Caida hplyot.obspm.fr 80
}
-- Opens Select File window --
alias sfile {
/ChangeStatus Select File please...
set %file $dir="Select file" $mircdir
if %file == $Null { /Changestatus Next time make up your mind... }
else { /changestatus File selected: ( $+ $nopath(%file) $+ ) Size: ( $+ $calc($lof(%file) / 1024) $+ ) kb }
}
-- Redraws @Crypt --
alias hilite {
/drawrect -fn @Crypt 1 1 27 42 168 17
/drawtext -n @Crypt 8 Arial 12 30 45 Choose File
/drawtext -n @Crypt 8 Arial 12 100 45 Encrypt
/drawrect -nf @Crypt 1 1 207 43 41 15
/drawtext -n @Crypt 8 Arial 12 209 45 Compare
/drawrect -n @Crypt 14 1 27 42 56 17
/drawrect -n @Crypt 14 1 97 42 39 17
/drawrect -n @Crypt 14 1 152 42 39 17
/drawtext -n @Crypt 8 Arial 12 155 45 Decrypt
/drawline -n @Crypt 4 1 27 41 250 41
/drawline -n @Crypt 4 1 27 60 250 60
/drawrect -n @Crypt 14 1 206 42 43 17
/drawline -n @Crypt 4 1 26 60 26 40
/drawline -n @Crypt 4 1 250 60 250 40
}
------------------ Performs button hiliting --------------------
alias hiliteCompare {
/hilite
/drawrect -fn @Crypt 2 1 207 43 41 15
/drawtext -n @Crypt 8 Arial 12 209 45 Compare
/drawrect @Crypt
}
alias hiliteChoose {
/hilite
/drawrect -fn @Crypt 2 1 28 43 54 15
/drawtext -n @Crypt 8 Arial 12 30 45 Choose File
/drawrect @Crypt
}
alias hiliteEncrypt {
/hilite
/drawrect -nf @Crypt 2 1 98 43 37 15
/drawtext -n @Crypt 8 Arial 12 100 45 Encrypt
/drawrect @Crypt
}
alias hiliteDecrypt {
/hilite
/drawrect -nf @Crypt 2 1 153 43 37 15
/drawtext -n @Crypt 8 Arial 12 155 45 Decrypt
/drawrect @Crypt
}
----------------------------------------------------------------------------------------------------
-- Makes @Ebox active --
alias ractive {
if $active == @Crypt {
/window -ra @Ebox
}
}
-- Performs file comparing, only works in Normal mode --
alias Comparefiles {
if $window(@Crypt).state == $null { /halt }
if $2 == $null { /beep | /changestatus Error need Two parameters use: /Comparefiles <Encoded> <Original> | /halt }
if $exists($1) == $false { /beep | /changestatus Error: ( $+ $1 $+ ) doesn't exist. | /halt }
if $exists($2) == $false { /beep | /changestatus Error: ( $+ $2 $+ ) doesn`t exist. | /halt }
if $lof($1) != $lof($2) { /changestatus File size is not equal, these are not the correct set of files | /halt }
if %mode == normal { /set %t 30 }
else if %mode == fast { /set %t 300 }
else if %mode == Ufast { /set %t 4000 }
if $lof($1) < 30 { /set %t $lof($1) }
/changestatus Reading bytes 1 to %t from ( $+ $1 $+ )
/bread $1 1 %t &bina
/changestatus Reading bytes 1 to %t from ( $+ $2 $+ )
/bread $2 1 %t &binb
/changestatus Comparing first %t bytes...
/write -c list.txt
set %nm 1
/unset %cbg
set %c 1
:R
if %c > %t && %cbg == $null { /goto done }
else if %c > %t { /goto found }
if $bvar(&bina,%c) > $bvar(&binb,%c) {
if $calc($bvar(&bina,%c) - $bvar(&binb,%c)) == $gettok(%cbg,%nm,44) {
if %nm == $gettok(%cbg,0,44) { /goto found }
/inc %nm 1
}
else /set %cbg %cbg $+ $calc($bvar(&bina,%c) - $bvar(&binb,%c)) $+ ,
}
if %mode == normal { /inc %c 1 }
else if %mode == fast { /inc %c 10 }
else { /inc %c 100 }
goto R
:found
/set %cp 1
/set %tp $gettok(%cbg,0,44)
/unset %pwd
:Rp
if %cp > %tp { /goto end }
set %pwd %pwd $+ $chr($gettok(%cbg,%cp,44))
inc %cp 1
goto RP
:end
/changestatus Possible password found: $right(%pwd,1) $+ $mid(%pwd,1,$calc($len(%pwd) - 1))
/editbox $right(%pwd,1) $+ $mid(%pwd,1,$calc($len(%pwd) - 1))
/halt
:done
/changestatus Password unretrievable
/halt
}
-- Opens and draws @Crypt --
alias Cryptwindow {
/window -ep +b @Crypt 0 0 300 120
/drawrect -fn @Crypt 1 1 0 0 300 100
/drawtext -n @Crypt 4 Arial 12 5 5 ©File Cipher© Copyright 1998 Brad Basler a.k.a danielson of Dalnet
/drawtext -n @Crypt 8 Arial 12 15 20 Status:
/drawline -n @Crypt 4 1 15 32 250 32
/drawline @Crypt
/changestatus Idleing...
/drawtext -n @Crypt 8 Arial 12 30 45 Choose File
/drawtext -n @Crypt 8 Arial 12 100 45 Encrypt
/drawrect -n @Crypt 14 1 27 42 56 17
/drawrect -n @Crypt 14 1 97 42 39 17
/drawrect -n @Crypt 14 1 152 42 39 17
/drawrect -n @Crypt 14 1 206 42 43 17
/drawtext -n @Crypt 8 Arial 12 155 45 Decrypt
/drawline -n @Crypt 4 1 27 41 250 41
/drawline -n @Crypt 4 1 27 60 250 60
/drawline -n @Crypt 4 1 26 60 26 40
/drawline -n @Crypt 4 1 250 60 250 40
/drawtext -n @Crypt 8 Arial 12 15 70 Percent:
/drawtext -n @Crypt 8 Arial 12 209 45 Compare
/drawrect -n @Crypt 14 1 55 70 202 12
/drawtext -n @Crypt 8 Arial 12 260 71 0%
/drawtext @Crypt
/window -ra @Crypt
}
-- Changes the percentage bar --
alias changepercent {
/drawrect -fn @Crypt 1 1 259 70 50 14
/drawrect -fn @Crypt 1 1 56 71 200 10
/drawrect -fn @Crypt 12 1 56 71 $calc($1 * 2) 10
/drawtext -n @Crypt 8 Arial 12 260 71 $1 $+ %
/drawtext @Crypt
}
-- Changes the text in status --
alias changestatus {
/drawrect -fn @Crypt 1 1 50 14 250 16
/drawtext -n @Crypt 8 Arial 12 50 20 $1-
/drawline @Crypt
}
-- Reads the data out of the file, should of used one alias --
alias DecryptFile {
set %cp 0
set %xp 4096
set %oj $lof(%file)
set %cgen 1
if %oj < 4096 {
/changestatus Reading bytes: %cp to %oj
/bread %file %cp %oj &binvar
/changestatus Decrypting bytes: %cp to %oj
/decrypt $1 %cp
if $server != $null { /raw -q PONG : $+ $server }
/bwrite %file %cp %oj &binvar
/changestatus Decryption Complete
/changepercent 100
/halt
}
:R
if %xp == %oj { /changestatus Decryption Complete | /changepercent 100 | /halt }
/changestatus Reading bytes: %cp to %oj
/bread %file %cp %xp &binvar
/changestatus Decrypting bytes: %cp to %xp
/decrypt $1 %cp
if $server != $null { /raw -q PONG : $+ $server }
/bwrite %file %cp %xp &binvar
if $calc(%xp + 4096 ) > %oj {
/set %cp $calc(%xp + 1)
/changestatus Reading bytes: %cp to %oj
/bread %file %cp %oj &binvar
/changestatus Decrypting bytes: %cp to %oj
/decrypt $1 %cp
if $server != $null { /raw -q PONG : $+ $server }
/bwrite %file %cp %oj &binvar
/changestatus Decryption Complete
/changepercent 100
/halt
}
/set %cp $calc(%xp + 1)
set %xp $calc(%cp + 4096)
goto R
}
-- Reads the data out of the file, should of used one alias --
alias EncryptFile {
set %cp 0
set %xp 4096
set %oj $lof(%file)
if %oj < 4096 {
/changestatus Reading bytes: %cp to %oj
/bread %file %cp %oj &binvar
/changestatus Encrypting bytes: %cp to %oj
/encrypt $1 %cp
if $server != $null { /raw -q PONG : $+ $server }
/bwrite %file %cp %oj &binvar
/changestatus Encryption Complete
/changepercent 100
/halt
}
:R
if %xp == %oj { /changestatus Encryption Complete | /changepercent 100 | /halt }
/changestatus Reading bytes: %cp to %xp
/bread %file %cp %xp &binvar
/changestatus Encrypting bytes: %cp to %xp
/encrypt $1 %cp
if $server != $null { /raw -q PONG : $+ $server }
/bwrite %file %cp %xp &binvar
if $calc(%xp + 4096 ) > %oj {
/set %cp $calc(%xp + 1)
/changestatus Reading bytes: %cp to %oj
/bread %file %cp %oj &binvar
/changestatus Encrypting bytes: %cp to %oj
/encrypt $1 %cp
if $server != $null { /raw -q PONG : $+ $server }
/bwrite %file %cp %oj &binvar
/changestatus Encryption Complete
/changepercent 100
/halt
}
/set %cp $calc(%xp + 1)
set %xp $calc(%cp + 4096)
goto R
}
-- Performs the actual Decryption --
alias Decrypt {
/unset %lastpercent
/set %c 1
/set %t $bvar(&binvar,0)
set %cgen 1
:R
if %c > %t { /return }
set %xps $bvar(&binvar,%c)
dec %xps $asc($mid($1,%cgen,1))
if %xps < 0 {
:x
/inc %xps 256
if %xps < 0 /goto X
}
/bset &binvar %c %xps
/set %bvalue $calc($calc(%c + $2) / $lof(%file) * 100)
if $int(%bvalue) != %lastpercent { /set %lastpercent %bvalue | /changepercent $int(%bvalue) }
if %mode == normal { /inc %c 1 }
else if %mode == fast { /inc %c 10 }
else { /inc %c 100 }
inc %cgen 1
if %cgen > $len($1) { /set %cgen 1 }
goto R
}
-- Performs the actual Encryption --
alias Encrypt {
/unset %lastpercent
/set %c 1
/set %t $bvar(&binvar,0)
set %cgen 1
:R
if %c > %t { /return }
set %xps $bvar(&binvar,%c)
inc %xps $asc($mid($1,%cgen,1))
if %xps > 255 {
:x
/dec %xps 256
if %xps > 255 /goto X
}
/bset &binvar %c %xps
/set %bvalue $calc($calc(%c + $2) / $lof(%file) * 100)
if $int(%bvalue) != %lastpercent { /set %lastpercent %bvalue | /changepercent $int(%bvalue) }
if %mode == normal { /inc %c 1 }
else if %mode == fast { /inc %c 10 }
else { /inc %c 100 }
inc %cgen 1
if %cgen > $len($1) { /set %cgen 1 }
goto R
}