Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DEFD = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,./<>?;'[]\:^"{}|`~!@#$%^^&*()_+-= ^t^n" // "
- DICT = "96p>.X#^t4/7A0^^5+,sHV<aLFT$E\D[3=]&KvtIzbm)?2q'MrUxQ1R%oecPn^ndyj{~^" }|ON-`;_GZk@CY!JhB*8S(lfuig:wW" // "
- genrnddict = [
- local tmp dict
- dict = $DEFD
- loop c (strlen $dict) [
- c = (substr $dict (rnd (strlen $dict)) 1)
- dict = (strreplace $dict $c "")
- tmp = (concatword $tmp $c)
- ]
- result $tmp
- ]
- // arg1 : message
- // arg2 : dictionary key
- // arg3 : private numerical key (8 numbers)
- testcrypto = [
- local output input
- input = (? $numargs $arg1 $DEFD)
- echo (concatword "^f8>>^f7" $input)
- output = (encrypt $input)
- echo (concatword "^f8:::::^f4" $output)
- output = (decrypt $output)
- echo (concatword "^f8<<" (? (=s $input $output) "^f9" "^f3") $output)
- ]
- encrypt = [
- local offset char len1 len2 rndp n0 n1 n2 n3 n4 n5 n6 n7 n8 n9
- arg2 = $DICT
- loop i 10 [ [n@i] = (strstr $arg2 $i) ]
- len1 = (strlen $arg1)
- len2 = (strlen $arg2)
- rndp = (& (rnd (pow (+ $n3 (* $n6 $n0)) (max 1 $n9))) 0xFF)
- arg1 = (concatword $arg1 (
- loopconcatword p $rndp [ result " " ]
- ) (tohex $rndp 2))
- len1 = (strlen $arg1)
- loopconcatword c $len1 [
- char = (substr $arg1 $c 1)
- offset = (mod (- (+ $offset (* $len1 $n0) (div (* $n1 $n2) $c) (sqrt (pow $n3 $n4))) (* $n5 $n6) (div $n7 $n8 $n9)) $len2)
- substr $arg2 ( mod (
- + (strstr $DEFD $char) $offset
- ) $len2 ) 1
- ]
- ]
- decrypt = [
- local offset char out len1 len2 n0 n1 n2 n3 n4 n5 n6 n7 n8 n9
- arg2 = $DICT
- len1 = (strlen $arg1)
- len2 = (strlen $arg2)
- loop i 10 [ [n@i] = (strstr $arg2 $i) ]
- out = (
- loopconcatword c $len1 [
- char = (substr $arg1 $c 1)
- offset = (mod (- (+ $offset (* $len1 $n0) (div (* $n1 $n2) $c) (sqrt (pow $n3 $n4))) (* $n5 $n6) (div $n7 $n8 $n9)) $len2)
- substr $DEFD ( mod (
- + (- (strstr $arg2 $char) $offset) $len2
- ) $len2 ) 1
- ]
- )
- substr $out 0 (- (strlen $out) (
- substr $out (- (strlen $out) 4) 4
- ) 4)
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement