@@ -32,12 +32,12 @@ module Serializable
3232 def serialize_payload ( message )
3333 serialized_data = serializer . dump ( message )
3434
35- return "#{ [ 0 ] . pack ( 'v' ) } #{ serialized_data } " if @options [ :pad_size ] . nil?
35+ return "#{ [ 0 ] . pack ( 'v' ) } #{ serialized_data . force_encoding ( Encoding :: BINARY ) } " if @options [ :pad_size ] . nil?
3636
3737 padding_bytes = @options [ :pad_size ] - ( 2 + serialized_data . size ) % @options [ :pad_size ]
3838 padding_data = SecureRandom . random_bytes ( padding_bytes )
3939
40- "#{ [ padding_bytes ] . pack ( 'v' ) } #{ padding_data } #{ serialized_data } "
40+ "#{ [ padding_bytes ] . pack ( 'v' ) } #{ padding_data } #{ serialized_data . force_encoding ( Encoding :: BINARY ) } "
4141 end
4242
4343 # Return the deserialized message. The first 2 bytes will be read as the
@@ -103,7 +103,7 @@ def initialize(secret, opts = {})
103103 serialize_json : false , pad_size : 32 , purpose : nil
104104 } . update ( opts )
105105
106- @hmac_secret = secret . dup . force_encoding ( ' BINARY' )
106+ @hmac_secret = secret . dup . force_encoding ( Encoding :: BINARY )
107107 @cipher_secret = @hmac_secret . slice! ( 0 , 32 )
108108
109109 @hmac_secret . freeze
@@ -250,7 +250,7 @@ def initialize(secret, opts = {})
250250 } . update ( opts )
251251 @options [ :serialize_json ] = true # Enforce JSON serialization
252252
253- @cipher_secret = secret . dup . force_encoding ( ' BINARY' ) . slice! ( 0 , 32 )
253+ @cipher_secret = secret . dup . force_encoding ( Encoding :: BINARY ) . slice! ( 0 , 32 )
254254 @cipher_secret . freeze
255255 end
256256
0 commit comments