Module: NewRelic::Agent::CrossAppMonitor::EncodingFunctions
- Defined in:
- lib/new_relic/agent/cross_app_monitor.rb
Overview
Functions for obfuscating and unobfuscating header values
Class Method Summary collapse
- .decode_with_key(key, text) ⇒ Object
- .encode_with_key(key, text) ⇒ Object
- .obfuscate_with_key(key, text) ⇒ Object
Class Method Details
.decode_with_key(key, text) ⇒ Object
37 38 39 |
# File 'lib/new_relic/agent/cross_app_monitor.rb', line 37 def decode_with_key(key, text) encode_with_key( key, text.unpack('m').first ) end |
.encode_with_key(key, text) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/new_relic/agent/cross_app_monitor.rb', line 41 def encode_with_key(key, text) return text unless key key = key.bytes.to_a if key.respond_to?( :bytes ) encoded = "" index = 0 text.each_byte do |byte| encoded.concat((byte ^ key[index % key.length].to_i)) index+=1 end encoded end |
.obfuscate_with_key(key, text) ⇒ Object
33 34 35 |
# File 'lib/new_relic/agent/cross_app_monitor.rb', line 33 def obfuscate_with_key(key, text) [ encode_with_key(key, text) ].pack('m').chomp.gsub(/\n/, '') end |