obfuskit 0.2.0 → 0.2.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
  SHA256:
3
- metadata.gz: 95df1da20d19fbbd42f0573e3373d1c08831f65f5a49365418fb98569a3d4c57
4
- data.tar.gz: 43964e64f7175109de2e033f538a1a42632ff4be5330fa30513fb53651f45a17
3
+ metadata.gz: f13c1d6e89c565ef55077edab6aeadaf16396a142887df8ccb8fc9e4c1939177
4
+ data.tar.gz: 281bc1d8a5517df52e6f71af31edd5430d52abc5f1a01e953b431c3c5f8f4cee
5
5
  SHA512:
6
- metadata.gz: d2e3716d091ee82c00a397a2d17bd610220bef2678c0402e75582b81c8f5491915b0003196e4e72951aa29a3634eb30223b7c83463a31635f87a3e68c3f47600
7
- data.tar.gz: 3086262688ba6c838a649a9bcbef677578a6001d5a716748ff0974046f511a58e4e556cd127bc316edfe5bf4e41f4cfde3e5791e9a9b475a2ca5f8fd545c562d
6
+ metadata.gz: 30d4652e43f1440ffc36b7c90541523719d0f7bb21f8d5d405571b1021f7f763ad6f4963ad2fb8e44532af1e47a9d72da547464b028369351aa512a955982532
7
+ data.tar.gz: 7fe5c1cfe3eaaf5ff2a11d0fd8d40d023bf4ccf6f8a2aefee2d77288437161e8975651697ee60ca1e5bbf2930a98e5328512cf2dafba34e08eb49ed107612561
@@ -11,23 +11,23 @@ module Obfuskit
11
11
  # The string is converted to an array of bytes and stored in @c.
12
12
  # The size of the array is stored in @l.
13
13
  def initialize(salt)
14
- salt = salt.bytes if salt.is_a? String
15
- @salt = salt
16
- @length = @salt.size
14
+ @salt = salt || ""
15
+ @salt_bytes = (salt.bytes || []) if salt.is_a? String
16
+ @salt_length = @salt_bytes.size
17
17
  end
18
18
 
19
19
  # Obfuscates a string.
20
20
  # The string is converted to an array of bytes and each element is XORed with an element from @c.
21
21
  # The index of the element from @c is the index of the element from the string modulo @l.
22
22
  def obfuscate(value)
23
- value.bytes.map.with_index { |b, i| b ^ @salt[i % @length] }
23
+ value.bytes.map.with_index { |b, i| b ^ @salt_bytes[i % @salt_length] }
24
24
  end
25
25
 
26
26
  # Reverses the obfuscation of an array of bytes.
27
27
  # Each element is XORed with an element from @c and the result is converted back to a string.
28
28
  # The index of the element from @c is the index of the element from the array modulo @l.
29
29
  def reveal(value)
30
- value.map.with_index { |b, i| b ^ @salt[i % @length] }.pack('C*').force_encoding('utf-8')
30
+ value.map.with_index { |b, i| b ^ @salt_bytes[i % @salt_length] }.pack('C*').force_encoding('utf-8')
31
31
  end
32
32
  end
33
33
  end
@@ -1,8 +1,8 @@
1
1
  package <%= package %>
2
2
 
3
3
  public object ObfusKit {
4
- private val _o = O(_6572131328ef462d9d4a05cf4b2a2516::class.java.simpleName)
5
- private class _6572131328ef462d9d4a05cf4b2a2516
4
+ private val _o = O(<%= salt %>::class.java.simpleName)
5
+ private class <%= salt %>
6
6
 
7
7
  <% values.each do |name, values| -%>
8
8
  public val <%= name %>: String = _o.r(byteArrayOf(<%= values.map { |i| i.to_s }.join(', ') %>))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Obfuskit
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/obfuskit.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/obfuskit/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "obfuskit"
7
+ s.version = Obfuskit::VERSION
8
+ s.summary = "Environment variable obfuscation for Swift and Kotlin."
9
+ s.description = "Generate Swift and Kotlin files with obfuscated environment variables."
10
+ s.authors = ["Martin Gratzer"]
11
+ s.email = "mgratzer@gmail.com"
12
+ s.homepage =
13
+ "https://github.com/mgratzer/obfuskit"
14
+ s.license = "MIT"
15
+ s.executables << "obfuskit"
16
+ s.required_ruby_version = ">= 3.0.0"
17
+ s.metadata["homepage_uri"] = s.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ s.files = Dir.chdir(__dir__) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ (File.expand_path(f) == __FILE__) ||
24
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
25
+ end
26
+ end
27
+ s.bindir = "exe"
28
+ s.executables = s.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ s.require_paths = ["lib"]
30
+ end
@@ -1,10 +1,13 @@
1
1
  module Obfuskit
2
2
  class Obfuscator
3
- @length: Integer
4
- @salt: String
3
+ attr_reader salt: String
5
4
 
6
- def salt: -> String
5
+ def initialize: (salt: String) -> void
7
6
  def obfuscate: (String) -> [Integer]
8
7
  def reveal: ([Integer]) -> String
8
+
9
+ private
10
+ attr_reader salt_length: Integer
11
+ attr_reader salt_bytes: [Integer]
9
12
  end
10
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obfuskit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Gratzer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-19 00:00:00.000000000 Z
11
+ date: 2024-02-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generate Swift and Kotlin files with obfuscated environment variables.
14
14
  email: mgratzer@gmail.com
@@ -26,6 +26,7 @@ files:
26
26
  - lib/obfuskit/templates/kotlin.erb
27
27
  - lib/obfuskit/templates/swift.erb
28
28
  - lib/obfuskit/version.rb
29
+ - obfuskit.gemspec
29
30
  - sig/obfuskit.rbs
30
31
  - sig/obfuskit/generator.rbs
31
32
  - sig/obfuskit/obfuscator.rbs
@@ -34,7 +35,7 @@ licenses:
34
35
  - MIT
35
36
  metadata:
36
37
  homepage_uri: https://github.com/mgratzer/obfuskit
37
- post_install_message:
38
+ post_install_message:
38
39
  rdoc_options: []
39
40
  require_paths:
40
41
  - lib
@@ -49,8 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
50
  - !ruby/object:Gem::Version
50
51
  version: '0'
51
52
  requirements: []
52
- rubygems_version: 3.5.3
53
- signing_key:
53
+ rubygems_version: 3.5.6
54
+ signing_key:
54
55
  specification_version: 4
55
56
  summary: Environment variable obfuscation for Swift and Kotlin.
56
57
  test_files: []