def encrypt(dek, salt, iter_mag=10)
      return nil if empty?
      raise Errors::InvalidSaltSize, 'too long' if salt.bytes.length > 255

      key, iv = _keyiv_gen(dek, salt, iter_mag)

      encryptor = OpenSSL::Cipher::AES256.new(:CBC).encrypt
      encryptor.key = key
      encryptor.iv = iv

      data_packet = _encrypted_data_header_v2(salt, iter_mag) + encryptor.update(self.to_json) + encryptor.final
      _append_crc32(data_packet)
    end
def encrypt(dek, salt, iter_mag=10)
      return nil if empty?
      raise Errors::InvalidSaltSize, 'too long' if salt.bytes.length > 255

      key, iv = _keyiv_gen(dek, salt, iter_mag)

      encryptor = OpenSSL::Cipher::AES256.new(:CBC).encrypt
      encryptor.key = key
      encryptor.iv = iv

      data_packet = _encrypted_data_header_v2(salt, iter_mag) + encryptor.update(self.to_json) + encryptor.final
      _append_crc32(data_packet)
    end
Encrypts the hash using the data encryption key and salt.

 Returns a blob:
 | Byte 0   |   Byte 1    |        Byte 2       | Bytes 3...S | Bytes S+1...E  | Bytes E+1..E+4 |
 ------------------------------------------------------------------------------------------------
 | Version  | Salt Length | Iteration Magnitude |     Salt    | Encrypted Data |     CRC32      |