xxtea-ruby 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efc56a30ea088303af96c80f4f36b5a809aa1bb0
4
- data.tar.gz: d46a9ccdadb94859bbe668d477abcd0f9c92fccf
3
+ metadata.gz: 9919007b9f52cde6b5dcd6a848dcd0ae8a847349
4
+ data.tar.gz: 206f55dfabdf1ecd24ab28c176d00e9c8805d82c
5
5
  SHA512:
6
- metadata.gz: 09c1d9fab2db59aa73713a8aabad63b9de3e992fa267a5be3659833a2fa4d0df7cc02f046ed54b0f4fe03e1c123f360a9f0e493655c5a97775ecfcb65f882d70
7
- data.tar.gz: b7d99f7446473f63820ac0d667969e760070a445622c25b1c6f0bb4a8e556b1a63cb575399c67bf4bdebe4c5c5e0a2a567351226fff0847219970321c76cb4ea
6
+ metadata.gz: 899cdb9b8344f2adb94184725a1622ec3d43cb110fc969cde797e0b09b3a6f92c8f816d13927327c8026429927255a87494d95c2ca87c29b61373926a60ad0d5
7
+ data.tar.gz: cc963729812d91248e91f4c4eccf19475e7471d548b7c433510413e91a95ccf26824ba2cec7394159e6b24086a7f00cae33c6a19dba0737a506c0b4460bc3481
@@ -9,7 +9,7 @@
9
9
  # Roger M. Needham #
10
10
  # #
11
11
  # Code Author: Ma Bingyao <mabingyao@gmail.com> #
12
- # LastModified: Feb 12, 2016 #
12
+ # LastModified: Feb 13, 2016 #
13
13
  # #
14
14
  ############################################################
15
15
 
@@ -21,7 +21,7 @@ else
21
21
  file.puts 'project(xxtea)'
22
22
  file.puts 'cmake_minimum_required(VERSION 2.6)'
23
23
  file.puts 'set(CMAKE_MACOSX_RPATH 1)' if RUBY_PLATFORM=~/darwin/
24
- file.puts 'set(LIBXXTEA_SRC ' + File.expand_path(File.dirname(__FILE__) + '/xxtea.c') +')'
24
+ file.puts 'set(LIBXXTEA_SRC ' + File.expand_path(File.join(File.dirname(__FILE__), 'xxtea.c')) +')'
25
25
  file.puts 'add_library(xxtea SHARED ${LIBXXTEA_SRC})'
26
26
  file.puts 'set_target_properties(xxtea PROPERTIES PREFIX "")'
27
27
  file.puts 'set_target_properties(xxtea PROPERTIES SUFFIX "")'
@@ -32,7 +32,7 @@ else
32
32
  else
33
33
  file.puts 'set_target_properties(xxtea PROPERTIES OUTPUT_NAME "xxtea.so")'
34
34
  end
35
- file.puts 'install(TARGETS xxtea DESTINATION ' + File.expand_path(File.dirname(__FILE__) + '/../../lib/xxtea') + ')'
35
+ file.puts 'install(TARGETS xxtea DESTINATION ' + File.expand_path(File.join(File.dirname(__FILE__), '../../lib/xxtea')) + ')'
36
36
  end
37
37
  system('cmake -G "Unix Makefiles" .')
38
38
  end
@@ -9,11 +9,11 @@
9
9
  # Roger M. Needham #
10
10
  # #
11
11
  # Code Author: Ma Bingyao <mabingyao@gmail.com> #
12
- # LastModified: Feb 12, 2016 #
12
+ # LastModified: Feb 13, 2016 #
13
13
  # #
14
14
  ############################################################
15
15
 
16
- if File.exists?(File.dirname(__FILE__) + '/xxtea.' + (RUBY_PLATFORM=~/darwin/ ? 'dylib' : RUBY_PLATFORM=~/win32|w32/ ? 'dll' : 'so')) then
16
+ if File.exists?(File.join(File.dirname(__FILE__), 'xxtea.' + (RUBY_PLATFORM=~/darwin/ ? 'dylib' : RUBY_PLATFORM=~/win32|w32/ ? 'dll' : 'so'))) then
17
17
  if !defined?(JRUBY_VERSION) then
18
18
  require "xxtea/xxtea"
19
19
  else
@@ -25,7 +25,7 @@ end
25
25
 
26
26
  module XXTEA
27
27
  extend self
28
- VERSION = "1.3.0"
28
+ VERSION = "1.3.1"
29
29
  if RUBY_VERSION >= "1.9.0" then
30
30
  def decrypt_utf8(data, key)
31
31
  decrypt(data, key).force_encoding(Encoding::UTF_8)
@@ -9,7 +9,7 @@
9
9
  # Roger M. Needham #
10
10
  # #
11
11
  # Code Author: Ma Bingyao <mabingyao@gmail.com> #
12
- # LastModified: Feb 12, 2016 #
12
+ # LastModified: Feb 13, 2016 #
13
13
  # #
14
14
  ############################################################
15
15
 
@@ -29,7 +29,7 @@ module XXTEA
29
29
  private
30
30
  module LIB
31
31
  extend FFI::Library
32
- ffi_lib File.dirname(__FILE__) + '/xxtea.' + (RUBY_PLATFORM=~/darwin/ ? 'dylib' : RUBY_PLATFORM=~/win32|w32/ ? 'dll' : 'so')
32
+ ffi_lib File.join(File.dirname(__FILE__), 'xxtea.' + (RUBY_PLATFORM=~/darwin/ ? 'dylib' : RUBY_PLATFORM=~/win32|w32/ ? 'dll' : 'so'))
33
33
  attach_function :xxtea_encrypt, [:pointer, :size_t, :pointer, :pointer], :pointer
34
34
  attach_function :xxtea_decrypt, [:pointer, :size_t, :pointer, :pointer], :pointer
35
35
  attach_function :free, [:pointer], :void
@@ -9,7 +9,7 @@
9
9
  # Roger M. Needham #
10
10
  # #
11
11
  # Code Author: Ma Bingyao <mabingyao@gmail.com> #
12
- # LastModified: Feb 11, 2016 #
12
+ # LastModified: Feb 13, 2016 #
13
13
  # #
14
14
  ############################################################
15
15
  module XXTEA
@@ -50,20 +50,24 @@ module XXTEA
50
50
  ((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4)) ^ ((sum ^ y) + (k[p & 3 ^ e] ^ z))
51
51
  end
52
52
 
53
+ def int32(i)
54
+ i & 0xffffffff
55
+ end
56
+
53
57
  def encrypt_uint32_array(v, k)
54
58
  n = v.size - 1
55
59
  z = v[n]
56
60
  y = 0
57
61
  sum = 0
58
62
  (6 + 52 / (n + 1)).downto(1) {
59
- sum = (sum + DELTA) & 0xffffffff
63
+ sum = int32(sum + DELTA)
60
64
  e = (sum >> 2) & 3
61
65
  for p in (0...n)
62
66
  y = v[p + 1]
63
- z = v[p] = (v[p] + mx(sum, y, z, p, e, k)) & 0xffffffff
67
+ z = v[p] = int32(v[p] + mx(sum, y, z, p, e, k))
64
68
  end
65
69
  y = v[0]
66
- z = v[n] = (v[n] + mx(sum, y, z, n, e, k)) & 0xffffffff
70
+ z = v[n] = int32(v[n] + mx(sum, y, z, n, e, k))
67
71
  }
68
72
  return v
69
73
  end
@@ -72,16 +76,16 @@ module XXTEA
72
76
  n = v.size - 1
73
77
  z = 0
74
78
  y = v[0]
75
- sum = ((6 + 52 / (n + 1)) * DELTA) & 0xffffffff
79
+ sum = int32((6 + 52 / (n + 1)) * DELTA)
76
80
  while (sum != 0)
77
81
  e = sum >> 2 & 3
78
82
  n.downto(1) { |p|
79
83
  z = v[p - 1]
80
- y = v[p] = (v[p] - mx(sum, y, z, p, e, k)) & 0xffffffff
84
+ y = v[p] = int32(v[p] - mx(sum, y, z, p, e, k))
81
85
  }
82
86
  z = v[n]
83
- y = v[0] = (v[0] - mx(sum, y, z, 0, e, k)) & 0xffffffff
84
- sum = (sum - DELTA) & 0xffffffff
87
+ y = v[0] = int32(v[0] - mx(sum, y, z, 0, e, k))
88
+ sum = int32(sum - DELTA)
85
89
  end
86
90
  return v
87
91
  end
@@ -1,6 +1,11 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'xxtea'
5
+
1
6
  Gem::Specification.new do |s|
2
7
  s.name = 'xxtea-ruby'
3
- s.version = '1.3.0'
8
+ s.version = XXTEA::VERSION
4
9
  s.license = 'MIT'
5
10
  s.author = 'Ma Bingyao ( andot )'
6
11
  s.email = 'mabingyao@gmail.com'
@@ -16,7 +21,7 @@ EOF
16
21
  s.files = `git ls-files`.split($/)
17
22
  s.test_files = s.files.grep(%r{^test/})
18
23
  s.require_path = 'lib'
19
- s.extensions = ["ext/xxtea/extconf.rb"]
24
+ s.extensions = ['ext/xxtea/extconf.rb']
20
25
 
21
26
  s.add_runtime_dependency 'ffi', '~> 1.9', '>= 1.9.10'
22
27
  s.requirements << 'cmake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xxtea-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ma Bingyao ( andot )
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi