fork download
  1. class String
  2. def from_hex()
  3. self.chop()
  4. string = self.scan(/[a-fA-F0-9]{2}/).map{|x| x.hex.chr}.join
  5. return string
  6. end
  7.  
  8. def to_hex()
  9. return self.split("").map{|x| x.unpack('H*')}.join
  10. end
  11.  
  12. def ^ (key) # Define an xor operator
  13. accum = []
  14. hex_bytes = []
  15. key_bytes = []
  16.  
  17. key = key.chr if key.is_a? Fixnum and key < 255 #Lets us handle Fixnum or String keys
  18. raise RangeError, "Integer Keys can be only 1 byte" if key.is_a? Fixnum #raise an error if it's too long
  19. raise "Invalid XOR key type #{key.class}" unless key.is_a? String #Else raise an exception
  20.  
  21. self.to_hex.split("").each_slice(2) {|x| hex_bytes << x.join}
  22. key.to_hex.split("").each_slice(2) {|x| key_bytes << x.join}
  23. hex_bytes.each_with_index{|h,i| accum << (h.to_i(16) ^ key_bytes[i.modulo key_bytes.size].to_i(16)).chr}
  24. return accum.join
  25. end
  26. end
  27.  
  28.  
  29. def cribdrag(ciphertext, crib)
  30. ciphertext.length.times{ |x| puts "#{x} : #{ciphertext[x,crib.length] ^ crib}"}
  31. end
  32.  
  33. fuck = "0f351c71c7654ff251de056ea68920cf2d7d49e53ff9174bd303fc04d74e7e69ad9cb9bf56160c2aea960d002b139b6b8f25982fe2e6e9f158a2451944c3f623d19dc425648beceb621f38768abb4f47ad46176b7b04b3c069a0c4da3b0dd3bea96a54b7e4453989f86b55ba8b635b90f944".from_hex ^ "0829003df52058a155c90553e9cc2cdc646f46a233f34347d542e8159e49713faad9a3a74753116ffb90484937468f6f9525bf28f2aaafe542b317080bc5e970829dc5287c8be8e130176d798bf6445aa34f1539121efbd56fe590d6374acaabbb725486ff4939a2e9394cb6957c56b4fd5798002ecccf00350445bc033eb8d79dc007fb2240f2afbbd3ec2b704f9b".from_hex
  34. cribdrag(fuck, "not")
Success #stdin #stdout #stderr 0.02s 6556KB
stdin
Standard input is empty
stdout
0 : ish
1 : rs8
2 : r#F
3 : "]1
4 : \*c
5 : +x'
6 : y<p
7 : =kc
8 : jxt
9 : yoI
10 : nR;
11 : S 1
12 : !*x
13 : +cg
14 : b|=
15 : }&f
16 : '}{
17 : |`3
18 : a(x
19 : )c~
20 : be 
21 : d;x
22 : :cr
23 : bi5
24 : h.`
25 : /{e
26 : z~=
27 : &s
28 : 'h{
29 : i`"
30 : a9s
31 : 8h1
32 : i*n
33 : +ul
34 : twe
35 : v~1
36 : *i
37 : +r1
38 : s*e
39 : +~r
40 : i1
41 : h*=
42 : +&h
43 : 's!
44 : r:`
45 : ;{p
46 : zkn
47 : jut
48 : toS
49 : nHs
50 : Ihd
51 : i8
52 : ~#2
53 : ")`
54 : ({n
55 : zue
56 : t~&
57 : =e
58 : <~;
59 :  r
60 : !ik
61 : hp'
62 : q<'
63 : =<t
64 : =ou
65 : nny
66 : obl
67 : cwt
68 : vop
69 : nk~
70 : je&
71 : d=|
72 : <g!
73 : f:{
74 : ;`u
75 : an9
76 : o"
77 : #di
78 : erz
79 : sa}
80 : `fv
81 : gm&
82 : l=
83 : <n
84 : u<
85 : t'a
86 : &zr
87 : {i1
88 : h* 
89 : +;x
90 : :cx
91 : bc3
92 : b(m
93 : )va
94 : wzf
95 : {}l
96 : |wt
97 : voE
98 : n^o
99 : _tx
100 : uct
101 : bo_
102 : nDe
103 : E~&
104 : =m
105 : <vx
106 : wcj
107 : bqk
108 : ppy
109 : qbP
110 : cKp
111 : Jkg
112 : j|
113 : }
stderr
prog.rb:17: warning: constant ::Fixnum is deprecated
prog.rb:18: warning: constant ::Fixnum is deprecated