crypto-toolbox 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65cce12b1b52be22312dcdbe387a696e0b5e2dbc
4
- data.tar.gz: 79e26f00e777f4f1fb76af853a171419f23aa1b2
3
+ metadata.gz: 6b4aeddf63a07920d3d86fb7e0414657b9760105
4
+ data.tar.gz: 14d41f8ef3a8180a7345b0ebfdc50aed896dde6a
5
5
  SHA512:
6
- metadata.gz: becd7a86fa057831193646cb161799c2f4dd85319990294b3c608b78c2b8cc774cefadd11d0306ac5b5c5f57cd82c419875f08b3cef36aacabd59bbf943b650f
7
- data.tar.gz: 00c1bba37d1e37691ee0245f5f8f09004751479bb5002fabe5b42e8222a9449161b39ef025d74e428097e98fa9d25d4256367e1fb801924a7a21cc930e6d704b
6
+ metadata.gz: c76e3531f39e618e8d73c23fa889ea1e0669dd6a8c05103f90ea31f197ba11955cfbe71606f534cc18899b0fd692a5b9d3f8d14e4c85668da28fe21d0c41348c
7
+ data.tar.gz: 36b518c0a99a911a205b2e5c29c12f7a9bbed101f0425e19b083acb9c6ada9d2623d4aa8a132acc5bf95959979886196f8e895f4bd526b221bdf1ddaf31ba880
@@ -25,7 +25,7 @@ module Analyzers
25
25
 
26
26
  def mac(message)
27
27
  connect unless @mac_socket
28
- packet = ( message.length.to_crypt_buffer + message + [0] ).chars.join("")
28
+ packet = assemble_mac_message(message)
29
29
 
30
30
  @mac_socket.write(packet)
31
31
  @mac_socket.read(16)
@@ -34,15 +34,23 @@ module Analyzers
34
34
  def verify(message,tag)
35
35
  connect unless @verify_socket
36
36
 
37
- # Message-length + message-chars + tag-chars + 0
38
- # NOTE: check why chars instead of bytes.map does not work here
39
- packet = (message.length.to_crypt_buffer + message + tag.split("") + [0] ).bytes.map(&:chr).join("")
37
+ packet = assemble_verify_message(message,tag)
40
38
 
41
39
  @verify_socket.write(packet)
42
40
  @verify_socket.read(2).to_i
43
41
  end
44
42
 
43
+ private
44
+
45
+ # Message-length + message-chars + tag-chars + 0
46
+ # NOTE: check why chars instead of bytes.map does not work here
47
+ def assemble_verify_message(message,tag)
48
+ (message.length.to_crypt_buffer + message + tag.split("") + [0] ).str
49
+ end
45
50
 
51
+ def assemble_mac_message(message)
52
+ ( message.length.to_crypt_buffer + message + [0] ).str
53
+ end
46
54
  end
47
55
  end
48
56
  end
@@ -1,5 +1,5 @@
1
1
  require 'ffi/hunspell'
2
- require 'ffi/aspell'
2
+ #require 'ffi/aspell'
3
3
 
4
4
  module Analyzers
5
5
  module Utils
@@ -7,7 +7,7 @@ module Analyzers
7
7
 
8
8
  def initialize(dict_lang="en_US")
9
9
  @dict = FFI::Hunspell.dict(dict_lang)
10
- @dict2 = FFI::Aspell::Speller.new(dict_lang)
10
+ # @dict2 = FFI::Aspell::Speller.new(dict_lang)
11
11
  end
12
12
  =begin
13
13
  NOTE: About spelling error rates and language detection:
@@ -76,7 +76,7 @@ if numbers or single char words are taken into account
76
76
  # which makes it slower than hunspell.
77
77
  # Thus we stick with hunspell for correctness and speed.
78
78
  def check?(input)
79
- @dict.check?(input)
79
+ @dict.check?(input) rescue false
80
80
  # @dict2.correct?(input.gsub(/[^a-zA-Z]/,""))
81
81
  end
82
82
 
@@ -54,6 +54,7 @@ module CryptBufferConcern
54
54
  def subset_padding
55
55
  last = bytes.last
56
56
  return [] if last.nil?
57
+ return [] if last >= length
57
58
  # e.g. 5: take from -5, 5 elems
58
59
  bytes[-1 * last, last]
59
60
  end
@@ -44,7 +44,18 @@ module CryptoChallanges
44
44
  end
45
45
 
46
46
  def solve8(ciphers)
47
- binding.pry
47
+ ciphers.map.with_index do |c,i|
48
+ if c.chunks_of(16).map(&:bytes).uniq.length < c.chunks_of(16).length
49
+ [i,c]
50
+ else
51
+ nil
52
+ end
53
+ # only resturn the first none nil value => compact.first
54
+ end.compact.first
55
+ end
56
+
57
+ def solve9(input)
58
+ CryptBuffer(input).pad(4).str
48
59
  end
49
60
  end
50
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crypto-toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Sivia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-15 00:00:00.000000000 Z
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aes