flatulent 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +60 -16
- data/flatulent-0.0.2.gem +0 -0
- data/lib/flatulent/crypt/blowfish-tables.rb +190 -0
- data/lib/flatulent/crypt/blowfish.rb +109 -0
- data/lib/flatulent/crypt/cbc.rb +123 -0
- data/lib/flatulent/crypt/gost.rb +140 -0
- data/lib/flatulent/crypt/idea.rb +193 -0
- data/lib/flatulent/crypt/noise.rb +94 -0
- data/lib/flatulent/crypt/purerubystringio.rb +378 -0
- data/lib/flatulent/crypt/rijndael-tables.rb +117 -0
- data/lib/flatulent/crypt/rijndael.rb +269 -0
- data/lib/flatulent/crypt/stringxor.rb +27 -0
- data/lib/flatulent.rb +332 -121
- data/lib/flatulent.rb.bak +337 -0
- data/rails/app/controllers/flatulent_controller.rb +61 -6
- data/rails/lib/flatulent/attributes.rb +79 -0
- data/rails/lib/flatulent/crypt/blowfish-tables.rb +190 -0
- data/rails/lib/flatulent/crypt/blowfish.rb +109 -0
- data/rails/lib/flatulent/crypt/cbc.rb +123 -0
- data/rails/lib/flatulent/crypt/gost.rb +140 -0
- data/rails/lib/flatulent/crypt/idea.rb +193 -0
- data/rails/lib/flatulent/crypt/noise.rb +94 -0
- data/rails/lib/flatulent/crypt/purerubystringio.rb +378 -0
- data/rails/lib/flatulent/crypt/rijndael-tables.rb +117 -0
- data/rails/lib/flatulent/crypt/rijndael.rb +269 -0
- data/rails/lib/flatulent/fontfiles/banner.flf +2494 -0
- data/rails/lib/flatulent/fontfiles/big.flf +2204 -0
- data/rails/lib/flatulent/fontfiles/block.flf +1691 -0
- data/rails/lib/flatulent/fontfiles/bubble.flf +1630 -0
- data/rails/lib/flatulent/fontfiles/digital.flf +1286 -0
- data/rails/lib/flatulent/fontfiles/ivrit.flf +900 -0
- data/rails/lib/flatulent/fontfiles/lean.flf +1691 -0
- data/rails/lib/flatulent/fontfiles/mini.flf +899 -0
- data/rails/lib/flatulent/fontfiles/mnemonic.flf +3702 -0
- data/rails/lib/flatulent/fontfiles/script.flf +1493 -0
- data/rails/lib/flatulent/fontfiles/shadow.flf +1097 -0
- data/rails/lib/flatulent/fontfiles/slant.flf +1295 -0
- data/rails/lib/flatulent/fontfiles/small.flf +1097 -0
- data/rails/lib/flatulent/fontfiles/smscript.flf +1097 -0
- data/rails/lib/flatulent/fontfiles/smshadow.flf +899 -0
- data/rails/lib/flatulent/fontfiles/smslant.flf +1097 -0
- data/rails/lib/flatulent/fontfiles/standard.flf +2227 -0
- data/rails/lib/flatulent/fontfiles/term.flf +600 -0
- data/rails/lib/flatulent/pervasives.rb +32 -0
- data/rails/lib/flatulent/stringxor.rb +27 -0
- data/rails/lib/flatulent/text/double_metaphone.rb +356 -0
- data/rails/lib/flatulent/text/figlet/font.rb +117 -0
- data/rails/lib/flatulent/text/figlet/smusher.rb +64 -0
- data/rails/lib/flatulent/text/figlet/typesetter.rb +68 -0
- data/rails/lib/flatulent/text/figlet.rb +17 -0
- data/rails/lib/flatulent/text/levenshtein.rb +65 -0
- data/rails/lib/flatulent/text/metaphone.rb +97 -0
- data/rails/lib/flatulent/text/porter_stemming.rb +171 -0
- data/rails/lib/flatulent/text/soundex.rb +61 -0
- data/rails/lib/flatulent/text.rb +6 -0
- data/rails/lib/flatulent.rb +450 -0
- data/rails/log/development.log +14297 -0
- data/rails/log/fastcgi.crash.log +111 -0
- data/rails/log/lighttpd.access.log +3993 -0
- data/rails/log/lighttpd.error.log +111 -0
- data/rails/tmp/cache/javascripts/prototype.js-gzip-3275912-71260-1183440172 +0 -0
- data/rails/tmp/sessions/ruby_sess.32d68bc997054475 +0 -0
- data/rails/tmp/sessions/ruby_sess.4694a4b9bdf9bcf4 +0 -0
- data/rails/tmp/sessions/ruby_sess.99469fde69043a05 +0 -0
- data/rails/tmp/sessions/ruby_sess.a588c0a457345912 +0 -0
- data/rails/tmp/sessions/ruby_sess.b3344125a84a3efa +0 -0
- data/samples.rb +10 -0
- metadata +69 -3
- data/flatulent-0.0.0.gem +0 -0
@@ -0,0 +1,378 @@
|
|
1
|
+
# Thanks to Binky DaClown who wrote this pure-ruby implementation
|
2
|
+
# http://rubyforge.org/projects/prstringio/
|
3
|
+
# Apparently CBC does not work well with the C-based stringio
|
4
|
+
|
5
|
+
module Crypt
|
6
|
+
class PureRubyStringIO
|
7
|
+
|
8
|
+
include Enumerable
|
9
|
+
|
10
|
+
SEEK_CUR = IO::SEEK_CUR
|
11
|
+
SEEK_END = IO::SEEK_END
|
12
|
+
SEEK_SET = IO::SEEK_SET
|
13
|
+
|
14
|
+
@@relayMethods = [:<<, :all?, :any?, :binmode, :close, :close_read, :close_write, :closed?, :closed_read?,
|
15
|
+
:closed_write?, :collect, :detect, :each, :each_byte, :each_line, :each_with_index,
|
16
|
+
:entries, :eof, :eof?, :fcntl, :fileno, :find, :find_all, :flush, :fsync, :getc, :gets,
|
17
|
+
:grep, :include?, :inject, :isatty, :length, :lineno, :lineno=, :map, :max, :member?,
|
18
|
+
:min, :partition, :path, :pid, :pos, :pos=, :print, :printf, :putc, :puts, :read,
|
19
|
+
:readchar, :readline, :readlines, :reject, :rewind, :seek, :select, :size, :sort,
|
20
|
+
:sort_by, :string, :string=, :sync, :sync=, :sysread, :syswrite, :tell, :truncate, :tty?,
|
21
|
+
:ungetc, :write, :zip]
|
22
|
+
|
23
|
+
def self.open(string="", mode="r+")
|
24
|
+
if block_given? then
|
25
|
+
sio = new(string, mode)
|
26
|
+
rc = yield(sio)
|
27
|
+
sio.close
|
28
|
+
rc
|
29
|
+
else
|
30
|
+
new(string, mode)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def <<(obj)
|
35
|
+
requireWritable
|
36
|
+
write obj
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def binmode
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
def close
|
45
|
+
requireOpen
|
46
|
+
@sio_closed_read = true
|
47
|
+
@sio_closed_write = true
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
def close_read
|
52
|
+
raise IOError, "closing non-duplex IO for reading", caller if closed_read?
|
53
|
+
@sio_closed_read = true
|
54
|
+
self
|
55
|
+
end
|
56
|
+
|
57
|
+
def close_write
|
58
|
+
raise IOError, "closing non-duplex IO for writing", caller if closed_write?
|
59
|
+
@sio_closed_read = true
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
def closed?
|
64
|
+
closed_read? && closed_write?
|
65
|
+
end
|
66
|
+
|
67
|
+
def closed_read?
|
68
|
+
@sio_closed_read
|
69
|
+
end
|
70
|
+
|
71
|
+
def closed_write?
|
72
|
+
@sio_closed_write
|
73
|
+
end
|
74
|
+
|
75
|
+
def each(sep_string=$/, &block)
|
76
|
+
requireReadable
|
77
|
+
@sio_string.each(sep_string, &block)
|
78
|
+
@sio_pos = @sio_string.length
|
79
|
+
end
|
80
|
+
|
81
|
+
def each_byte(&block)
|
82
|
+
requireReadable
|
83
|
+
@sio_string.each_byte(&block)
|
84
|
+
@sio_pos = @sio_string.length
|
85
|
+
end
|
86
|
+
|
87
|
+
def eof
|
88
|
+
requireReadable { @sio_pos >= @sio_string.length }
|
89
|
+
end
|
90
|
+
|
91
|
+
def fcntl(integer_cmd, arg)
|
92
|
+
raise NotImplementedError, "The fcntl() function is unimplemented on this machine", caller
|
93
|
+
end
|
94
|
+
|
95
|
+
def fileno
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
|
99
|
+
def flush
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
103
|
+
def fsync
|
104
|
+
0
|
105
|
+
end
|
106
|
+
|
107
|
+
def getc
|
108
|
+
requireReadable
|
109
|
+
char = @sio_string[@sio_pos]
|
110
|
+
@sio_pos += 1 unless char.nil?
|
111
|
+
char
|
112
|
+
end
|
113
|
+
|
114
|
+
def gets(sep_string=$/)
|
115
|
+
requireReadable
|
116
|
+
@sio_lineno += 1
|
117
|
+
pstart = @sio_pos
|
118
|
+
@sio_pos = @sio_string.index(sep_string, @sio_pos) || [@sio_string.length, @sio_pos].max
|
119
|
+
@sio_string[pstart..@sio_pos]
|
120
|
+
end
|
121
|
+
|
122
|
+
def initialize(string="", mode="r+")
|
123
|
+
@sio_string = string.to_s
|
124
|
+
@sio_lineno = 0
|
125
|
+
@mode = mode
|
126
|
+
@relay = nil
|
127
|
+
case mode.delete("b")
|
128
|
+
when "r"
|
129
|
+
@sio_closed_read = false
|
130
|
+
@sio_closed_write = true
|
131
|
+
@sio_pos = 0
|
132
|
+
when "r+"
|
133
|
+
@sio_closed_read = false
|
134
|
+
@sio_closed_write = false
|
135
|
+
@sio_pos = 0
|
136
|
+
when "w"
|
137
|
+
@sio_closed_read = true
|
138
|
+
@sio_closed_write = false
|
139
|
+
@sio_pos = 0
|
140
|
+
@sio_string.replace("")
|
141
|
+
when "w+"
|
142
|
+
@sio_closed_read = false
|
143
|
+
@sio_closed_write = false
|
144
|
+
@sio_pos = 0
|
145
|
+
@sio_string.replace("")
|
146
|
+
when "a"
|
147
|
+
@sio_closed_read = true
|
148
|
+
@sio_closed_write = false
|
149
|
+
@sio_pos = @sio_string.length
|
150
|
+
when "a+"
|
151
|
+
@sio_closed_read = false
|
152
|
+
@sio_closed_write = false
|
153
|
+
@sio_pos = @sio_string.length
|
154
|
+
else
|
155
|
+
raise ArgumentError, "illegal access mode #{mode}", caller
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def isatty
|
160
|
+
flase
|
161
|
+
end
|
162
|
+
|
163
|
+
def length
|
164
|
+
@sio_string.length
|
165
|
+
end
|
166
|
+
|
167
|
+
def lineno
|
168
|
+
@sio_lineno
|
169
|
+
end
|
170
|
+
|
171
|
+
def lineno=(integer)
|
172
|
+
@sio_lineno = integer
|
173
|
+
end
|
174
|
+
|
175
|
+
def path
|
176
|
+
nil
|
177
|
+
end
|
178
|
+
|
179
|
+
def pid
|
180
|
+
nil
|
181
|
+
end
|
182
|
+
|
183
|
+
def pos
|
184
|
+
@sio_pos
|
185
|
+
end
|
186
|
+
|
187
|
+
def pos=(integer)
|
188
|
+
raise Errno::EINVAL, "Invalid argument", caller if integer < 0
|
189
|
+
@sio_pos = integer
|
190
|
+
end
|
191
|
+
|
192
|
+
def print(*args)
|
193
|
+
requireWritable
|
194
|
+
args.unshift($_) if args.empty
|
195
|
+
args.each { |obj| write(obj) }
|
196
|
+
write($\) unless $\.nil?
|
197
|
+
nil
|
198
|
+
end
|
199
|
+
|
200
|
+
def printf(format_string, *args)
|
201
|
+
requireWritable
|
202
|
+
write format(format_string, *args)
|
203
|
+
nil
|
204
|
+
end
|
205
|
+
|
206
|
+
def putc(obj)
|
207
|
+
requireWritable
|
208
|
+
write(obj.is_a?(Numeric) ? sprintf("%c", obj) : obj.to_s[0..0])
|
209
|
+
obj
|
210
|
+
end
|
211
|
+
|
212
|
+
def puts(*args)
|
213
|
+
requireWritable
|
214
|
+
args.unshift("") if args.empty?
|
215
|
+
args.each { |obj|
|
216
|
+
write obj
|
217
|
+
write $/
|
218
|
+
}
|
219
|
+
nil
|
220
|
+
end
|
221
|
+
|
222
|
+
def read(length=nil, buffer=nil)
|
223
|
+
requireReadable
|
224
|
+
len = length || [@sio_string.length - @sio_pos, 0].max
|
225
|
+
raise ArgumentError, "negative length #{len} given", caller if len < 0
|
226
|
+
buffer ||= ""
|
227
|
+
pstart = @sio_pos
|
228
|
+
@sio_pos += len
|
229
|
+
buffer.replace(@sio_string[pstart..@sio_pos])
|
230
|
+
buffer.empty? && !length.nil? ? nil : buffer
|
231
|
+
end
|
232
|
+
|
233
|
+
def readchar
|
234
|
+
requireReadable
|
235
|
+
raise EOFError, "End of file reached", caller if eof?
|
236
|
+
getc
|
237
|
+
end
|
238
|
+
|
239
|
+
def readline
|
240
|
+
requireReadable
|
241
|
+
raise EOFError, "End of file reached", caller if eof?
|
242
|
+
gets
|
243
|
+
end
|
244
|
+
|
245
|
+
def readlines(sep_string=$/)
|
246
|
+
requireReadable
|
247
|
+
raise EOFError, "End of file reached", caller if eof?
|
248
|
+
rc = []
|
249
|
+
until eof
|
250
|
+
rc << gets(sep_string)
|
251
|
+
end
|
252
|
+
rc
|
253
|
+
end
|
254
|
+
|
255
|
+
def reopen(string, mode=nil)
|
256
|
+
if string.is_a?(self.class) then
|
257
|
+
raise ArgumentError, "wrong number of arguments (2 for 1)", caller if !mode.nil?
|
258
|
+
@relay = string
|
259
|
+
instance_eval(%Q{
|
260
|
+
class << self
|
261
|
+
@@relayMethods.each { |name|
|
262
|
+
define_method(name, ObjectSpace._id2ref(#{@relay.object_id}).method(("original_" + name.to_s).to_sym).to_proc)
|
263
|
+
}
|
264
|
+
end
|
265
|
+
})
|
266
|
+
else
|
267
|
+
raise ArgumentError, "wrong number of arguments (1 for 2)", caller if mode.nil?
|
268
|
+
class << self
|
269
|
+
@@relayMethods.each { |name|
|
270
|
+
alias_method(name, "original_#{name}".to_sym)
|
271
|
+
public name
|
272
|
+
}
|
273
|
+
@relay = nil
|
274
|
+
end unless @relay.nil?
|
275
|
+
@sio_string = string.to_s
|
276
|
+
@mode = mode
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def rewind
|
281
|
+
@sio_pos = 0
|
282
|
+
@sio_lineno = 0
|
283
|
+
end
|
284
|
+
|
285
|
+
def seek(amount, whence=SEEK_SET)
|
286
|
+
if whence == SEEK_CUR then
|
287
|
+
offset += @sio_pos
|
288
|
+
elsif whence == SEEK_END then
|
289
|
+
offset += size
|
290
|
+
end
|
291
|
+
@sio_pos = offset
|
292
|
+
end
|
293
|
+
|
294
|
+
def string
|
295
|
+
@sio_string
|
296
|
+
end
|
297
|
+
|
298
|
+
def string=(newstring)
|
299
|
+
@sio_string = newstring
|
300
|
+
end
|
301
|
+
|
302
|
+
def sync
|
303
|
+
true
|
304
|
+
end
|
305
|
+
|
306
|
+
def sync=(boolean)
|
307
|
+
boolean
|
308
|
+
end
|
309
|
+
|
310
|
+
def sysread(length=nil, buffer=nil)
|
311
|
+
requireReadable
|
312
|
+
raise EOFError, "End of file reached", caller if eof?
|
313
|
+
read(length, buffer)
|
314
|
+
end
|
315
|
+
|
316
|
+
def syswrite(string)
|
317
|
+
requireWritable
|
318
|
+
addition = "\000" * (@sio_string.length - @sio_pos) + string.to_s
|
319
|
+
@sio_string[@sio_pos..(addition.length - 1)] = addition
|
320
|
+
@sio_pos += addition.size
|
321
|
+
addition.size
|
322
|
+
end
|
323
|
+
|
324
|
+
#In ruby 1.8.4 truncate differs from the docs in two ways.
|
325
|
+
#First, if an integer greater that the length is given then the string is expanded to the new integer
|
326
|
+
#length. As this expansion seems to contain junk characters instead of nulls I suspect this may be a
|
327
|
+
#flaw in the C code which could cause a core dump if abused/used.
|
328
|
+
#Second, the documentation states that truncate returns 0. It returns the integer instead.
|
329
|
+
#This implementation follows the documentation in the first instance as I suspect this will be fixed
|
330
|
+
#in the C code. In the second instance, it follows the actions of the C code instead of the docs.
|
331
|
+
#This was decided as it causes no immedeate harm and this ruby implentation is to be as compatable
|
332
|
+
#as possible with the C version. Should the C version change to match the docs the ruby version
|
333
|
+
#will be simple to update as well.
|
334
|
+
def truncate(integer)
|
335
|
+
requireWritable
|
336
|
+
raise Errno::EINVAL, "Invalid argument - negative length", caller if integer < 0
|
337
|
+
@sio_string[[integer, @sio_string.length].max..-1] = ""
|
338
|
+
integer
|
339
|
+
end
|
340
|
+
|
341
|
+
def ungetc(integer)
|
342
|
+
requireWritable
|
343
|
+
if @sio_pos > 0 then
|
344
|
+
@sio_pos -= 1
|
345
|
+
putc(integer)
|
346
|
+
@sio_pos -= 1
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
alias :each_line :each
|
351
|
+
alias :eof? :eof
|
352
|
+
alias :size :length
|
353
|
+
alias :tty? :isatty
|
354
|
+
alias :tell :pos
|
355
|
+
alias :write :syswrite
|
356
|
+
|
357
|
+
protected
|
358
|
+
@@relayMethods.each { |name|
|
359
|
+
alias_method("original_#{name}".to_sym, name)
|
360
|
+
protected "original_#{name}".to_sym
|
361
|
+
}
|
362
|
+
|
363
|
+
private
|
364
|
+
|
365
|
+
def requireReadable
|
366
|
+
raise IOError, "not opened for reading", caller[1..-1] if @sio_closed_read
|
367
|
+
end
|
368
|
+
|
369
|
+
def requireWritable
|
370
|
+
raise IOError, "not opened for writing", caller[1..-1] if @sio_closed_write
|
371
|
+
end
|
372
|
+
|
373
|
+
def requireOpen
|
374
|
+
raise IOError, "closed stream", caller[1..-1] if @sio_closed_read && @sio_closed_write
|
375
|
+
end
|
376
|
+
|
377
|
+
end
|
378
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# rijndael-tables.rb Richard Kernahan <kernighan_rich@rubyforge.org>
|
2
|
+
|
3
|
+
module Crypt
|
4
|
+
module RijndaelTables
|
5
|
+
|
6
|
+
LogTable = [
|
7
|
+
0, 0, 25, 1, 50, 2, 26, 198, 75, 199, 27, 104, 51, 238, 223, 3,
|
8
|
+
100, 4, 224, 14, 52, 141, 129, 239, 76, 113, 8, 200, 248, 105, 28, 193,
|
9
|
+
125, 194, 29, 181, 249, 185, 39, 106, 77, 228, 166, 114, 154, 201, 9, 120,
|
10
|
+
101, 47, 138, 5, 33, 15, 225, 36, 18, 240, 130, 69, 53, 147, 218, 142,
|
11
|
+
150, 143, 219, 189, 54, 208, 206, 148, 19, 92, 210, 241, 64, 70, 131, 56,
|
12
|
+
102, 221, 253, 48, 191, 6, 139, 98, 179, 37, 226, 152, 34, 136, 145, 16,
|
13
|
+
126, 110, 72, 195, 163, 182, 30, 66, 58, 107, 40, 84, 250, 133, 61, 186,
|
14
|
+
43, 121, 10, 21, 155, 159, 94, 202, 78, 212, 172, 229, 243, 115, 167, 87,
|
15
|
+
175, 88, 168, 80, 244, 234, 214, 116, 79, 174, 233, 213, 231, 230, 173, 232,
|
16
|
+
44, 215, 117, 122, 235, 22, 11, 245, 89, 203, 95, 176, 156, 169, 81, 160,
|
17
|
+
127, 12, 246, 111, 23, 196, 73, 236, 216, 67, 31, 45, 164, 118, 123, 183,
|
18
|
+
204, 187, 62, 90, 251, 96, 177, 134, 59, 82, 161, 108, 170, 85, 41, 157,
|
19
|
+
151, 178, 135, 144, 97, 190, 220, 252, 188, 149, 207, 205, 55, 63, 91, 209,
|
20
|
+
83, 57, 132, 60, 65, 162, 109, 71, 20, 42, 158, 93, 86, 242, 211, 171,
|
21
|
+
68, 17, 146, 217, 35, 32, 46, 137, 180, 124, 184, 38, 119, 153, 227, 165,
|
22
|
+
103, 74, 237, 222, 197, 49, 254, 24, 13, 99, 140, 128, 192, 247, 112, 7
|
23
|
+
]
|
24
|
+
|
25
|
+
AlogTable = [
|
26
|
+
1, 3, 5, 15, 17, 51, 85, 255, 26, 46, 114, 150, 161, 248, 19, 53,
|
27
|
+
95, 225, 56, 72, 216, 115, 149, 164, 247, 2, 6, 10, 30, 34, 102, 170,
|
28
|
+
229, 52, 92, 228, 55, 89, 235, 38, 106, 190, 217, 112, 144, 171, 230, 49,
|
29
|
+
83, 245, 4, 12, 20, 60, 68, 204, 79, 209, 104, 184, 211, 110, 178, 205,
|
30
|
+
76, 212, 103, 169, 224, 59, 77, 215, 98, 166, 241, 8, 24, 40, 120, 136,
|
31
|
+
131, 158, 185, 208, 107, 189, 220, 127, 129, 152, 179, 206, 73, 219, 118, 154,
|
32
|
+
181, 196, 87, 249, 16, 48, 80, 240, 11, 29, 39, 105, 187, 214, 97, 163,
|
33
|
+
254, 25, 43, 125, 135, 146, 173, 236, 47, 113, 147, 174, 233, 32, 96, 160,
|
34
|
+
251, 22, 58, 78, 210, 109, 183, 194, 93, 231, 50, 86, 250, 21, 63, 65,
|
35
|
+
195, 94, 226, 61, 71, 201, 64, 192, 91, 237, 44, 116, 156, 191, 218, 117,
|
36
|
+
159, 186, 213, 100, 172, 239, 42, 126, 130, 157, 188, 223, 122, 142, 137, 128,
|
37
|
+
155, 182, 193, 88, 232, 35, 101, 175, 234, 37, 111, 177, 200, 67, 197, 84,
|
38
|
+
252, 31, 33, 99, 165, 244, 7, 9, 27, 45, 119, 153, 176, 203, 70, 202,
|
39
|
+
69, 207, 74, 222, 121, 139, 134, 145, 168, 227, 62, 66, 198, 81, 243, 14,
|
40
|
+
18, 54, 90, 238, 41, 123, 141, 140, 143, 138, 133, 148, 167, 242, 13, 23,
|
41
|
+
57, 75, 221, 124, 132, 151, 162, 253, 28, 36, 108, 180, 199, 82, 246, 1
|
42
|
+
]
|
43
|
+
|
44
|
+
S = [
|
45
|
+
99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118,
|
46
|
+
202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192,
|
47
|
+
183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21,
|
48
|
+
4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117,
|
49
|
+
9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132,
|
50
|
+
83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207,
|
51
|
+
208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168,
|
52
|
+
81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210,
|
53
|
+
205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115,
|
54
|
+
96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219,
|
55
|
+
224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121,
|
56
|
+
231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8,
|
57
|
+
186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138,
|
58
|
+
112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158,
|
59
|
+
225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223,
|
60
|
+
140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22
|
61
|
+
]
|
62
|
+
|
63
|
+
Si = [
|
64
|
+
82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251,
|
65
|
+
124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203,
|
66
|
+
84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78,
|
67
|
+
8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37,
|
68
|
+
114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146,
|
69
|
+
108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132,
|
70
|
+
144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6,
|
71
|
+
208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107,
|
72
|
+
58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115,
|
73
|
+
150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110,
|
74
|
+
71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27,
|
75
|
+
252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244,
|
76
|
+
31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95,
|
77
|
+
96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239,
|
78
|
+
160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97,
|
79
|
+
23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125,
|
80
|
+
]
|
81
|
+
|
82
|
+
IG = [
|
83
|
+
[0x0e, 0x09, 0x0d, 0x0b],
|
84
|
+
[0x0b, 0x0e, 0x09, 0x0d],
|
85
|
+
[0x0d, 0x0b, 0x0e, 0x09],
|
86
|
+
[0x09, 0x0d, 0x0b, 0x0e]
|
87
|
+
]
|
88
|
+
|
89
|
+
Rcon = [
|
90
|
+
0x01, 0x02, 0x04, 0x08, 0x10, 0x20,
|
91
|
+
0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8,
|
92
|
+
0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc,
|
93
|
+
0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4,
|
94
|
+
0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91
|
95
|
+
]
|
96
|
+
|
97
|
+
Shifts = [
|
98
|
+
[
|
99
|
+
[0, 0],
|
100
|
+
[1, 3],
|
101
|
+
[2, 2],
|
102
|
+
[3, 1]
|
103
|
+
], [
|
104
|
+
[0, 0],
|
105
|
+
[1, 5],
|
106
|
+
[2, 4],
|
107
|
+
[3, 3]
|
108
|
+
], [
|
109
|
+
[0, 0],
|
110
|
+
[1, 7],
|
111
|
+
[3, 5],
|
112
|
+
[4, 4]
|
113
|
+
]
|
114
|
+
]
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|