Advertisement
RaZgRiZ

8924th SUBcipher DEMO

Aug 30th, 2016
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. DEFD = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,./<>?;'[]\:^"{}|`~!@#$%^^&*()_+-= ^t^n" // "
  2. DICT = "96p>.X#^t4/7A0^^5+,sHV<aLFT$E\D[3=]&KvtIzbm)?2q'MrUxQ1R%oecPn^ndyj{~^" }|ON-`;_GZk@CY!JhB*8S(lfuig:wW" // "
  3.  
  4. genrnddict = [
  5.     local tmp dict
  6.     dict = $DEFD
  7.     loop c (strlen $dict) [
  8.         c = (substr $dict (rnd (strlen $dict)) 1)
  9.         dict = (strreplace $dict $c "")
  10.         tmp = (concatword $tmp $c)
  11.     ]
  12.     result $tmp
  13. ]
  14.  
  15.  
  16. // arg1 : message
  17. // arg2 : dictionary key
  18. // arg3 : private numerical key (8 numbers)
  19.  
  20. testcrypto = [
  21.     local output input
  22.     input = (? $numargs $arg1 $DEFD)
  23.     echo (concatword "^f8>>^f7" $input)
  24.     output = (encrypt $input)
  25.     echo (concatword "^f8:::::^f4" $output)
  26.     output = (decrypt $output)
  27.     echo (concatword "^f8<<" (? (=s $input $output) "^f9" "^f3") $output)
  28. ]
  29.  
  30. encrypt = [
  31.     local offset char len1 len2 rndp n0 n1 n2 n3 n4 n5 n6 n7 n8 n9
  32.     arg2 = $DICT
  33.     loop i 10 [ [n@i] = (strstr $arg2 $i) ]
  34.     len1 = (strlen $arg1)
  35.     len2 = (strlen $arg2)
  36.     rndp = (& (rnd (pow (+ $n3 (* $n6 $n0)) (max 1 $n9))) 0xFF)
  37.     arg1 = (concatword $arg1 (
  38.         loopconcatword p $rndp [ result " " ]
  39.     ) (tohex $rndp 2))
  40.     len1 = (strlen $arg1)
  41.     loopconcatword c $len1 [
  42.         char = (substr $arg1 $c 1)
  43.         offset = (mod (- (+ $offset (* $len1 $n0) (div (* $n1 $n2) $c) (sqrt (pow $n3 $n4))) (* $n5 $n6) (div $n7 $n8 $n9)) $len2)
  44.         substr $arg2 ( mod (
  45.             + (strstr $DEFD $char) $offset
  46.         ) $len2 ) 1
  47.     ]
  48. ]
  49.  
  50. decrypt = [
  51.     local offset char out len1 len2 n0 n1 n2 n3 n4 n5 n6 n7 n8 n9
  52.     arg2 = $DICT
  53.     len1 = (strlen $arg1)
  54.     len2 = (strlen $arg2)
  55.     loop i 10 [ [n@i] = (strstr $arg2 $i) ]
  56.     out = (
  57.         loopconcatword c $len1 [
  58.             char = (substr $arg1 $c 1)
  59.             offset = (mod (- (+ $offset (* $len1 $n0) (div (* $n1 $n2) $c) (sqrt (pow $n3 $n4))) (* $n5 $n6) (div $n7 $n8 $n9)) $len2)
  60.             substr $DEFD ( mod (
  61.                 + (- (strstr $arg2 $char) $offset) $len2
  62.             ) $len2 ) 1
  63.         ]
  64.     )
  65.     substr $out 0 (- (strlen $out) (
  66.         substr $out (- (strlen $out) 4) 4
  67.     ) 4)
  68. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement