Skip to content

Commit

Permalink
fix(crypto): revert crypto module name
Browse files Browse the repository at this point in the history
  • Loading branch information
parfeon committed Sep 29, 2023
1 parent 80398f6 commit 0d642c5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/pubnub/cryptor.rb → lib/pubnub/crypto.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Toplevel Pubnub module.
module Pubnub
# Internal Crypto class used for message encryption and decryption
class Cryptor
class Crypto
def initialize(cipher_key, use_random_iv)
@alg = 'AES-256-CBC'
sha256_key = Digest::SHA256.hexdigest(cipher_key.to_s)
Expand Down
2 changes: 1 addition & 1 deletion lib/pubnub/events/history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def valid_envelope(parsed_response, req_res_objects)
if (@cipher_key || @app.env[:cipher_key] || @cipher_key_selector || @app.env[:cipher_key_selector]) && messages
cipher_key = compute_cipher_key(parsed_response)
random_iv = compute_random_iv(parsed_response)
crypto = Cryptor.new(cipher_key, random_iv)
crypto = Crypto.new(cipher_key, random_iv)
messages = messages.map { |message| decrypt_history(message, crypto) }
end

Expand Down
2 changes: 1 addition & 1 deletion lib/pubnub/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def format_uuid(uuids, should_encode = true)
# Transforms message to json and encode it
def format_message(message, cipher_key = '', use_random_iv = false, uri_escape = true)
if cipher_key && !cipher_key.empty?
pc = Pubnub::Cryptor.new(cipher_key, use_random_iv)
pc = Pubnub::Crypto.new(cipher_key, use_random_iv)
message = pc.encrypt(message).to_json
message = Addressable::URI.escape(message) if uri_escape
else
Expand Down
2 changes: 1 addition & 1 deletion lib/pubnub/subscribe_event/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def decipher_payload(message)
data = message.reject { |k, _v| k == :payload }
cipher_key = compute_cipher_key(data)
random_iv = compute_random_iv(data)
crypto = Pubnub::Cryptor.new(cipher_key, random_iv)
crypto = Pubnub::Crypto.new(cipher_key, random_iv)
JSON.parse(crypto.decrypt(message[:payload]), quirks_mode: true)
rescue StandardError, UnknownCryptorError
message[:payload]
Expand Down

0 comments on commit 0d642c5

Please sign in to comment.