Class: Fastlane::Helper::SecretsHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/secrets/helper/secrets_helper.rb

Class Method Summary collapse

Class Method Details

.inject_secrets(secret_bytes, file) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/fastlane/plugin/secrets/helper/secrets_helper.rb', line 9

def self.inject_secrets(secret_bytes, file)
  template = IO.read "#{__dir__}/SecretsTemplate.swift"
  secret_bytes = "#{secret_bytes}".gsub "],", "],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
  bytes_variable = "private let bytes: [[UInt8]] = #{secret_bytes}"
  swift_secrets = template.sub "/* SECRET BYTES */", bytes_variable

  File.open(file, "w") do |f|
    f.puts swift_secrets
  end
end

.xor_chiper(key, string) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/fastlane/plugin/secrets/helper/secrets_helper.rb', line 20

def self.xor_chiper(key, string)
  key_chars = key.chars
  result = ""
  codepoints = string.each_codepoint.to_a
  codepoints.each_index do |i|
    result += (codepoints[i] ^ key_chars[i % key_chars.size].ord).chr
  end
  result
end