Method: VChainClient::Crypto#encodeCypher

Defined in:
lib/vchain_client/crypto.rb

#encodeCypher(document) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/vchain_client/crypto.rb', line 168

def encodeCypher(document)
      cif = OpenSSL::Cipher.new('AES-256-CTR')

      cif.encrypt

      cif.key = key = cif.random_key
      cif.iv  = iv  = cif.random_iv

      out = {
        "payload" => (cif.update(document) + cif.final),
        "key" => key,
        "iv" => iv
      }

      return out
end