input: Write a function to create a basic blockchain system in Python that includes functions to generate SHA256 hashes and create and add blocks to a blockchain. The function should also return the entire blockchain in JSON format when called.
  assert create_blockchain([])==None
  assert create_blockchain([{'timestamp': '2023-10-01', 'data': 'First block'}])==json.dumps([{
    'index': 0,
    'timestamp': '2023-10-01',
    'data': 'First block',
    'previous_hash': None,
    'hash': '8b1efa6ff6f8e3b34ac7661ba38f6a1f0c97d55b664f4febb8b25e2abbc39a0b'
  }], indent=2)
  assert create_blockchain([
      {'timestamp': '2023-10-01', 'data': 'First block'},
      {'timestamp': '2023-10-02', 'data': 'Second block'}
  ])==json.dumps([
    {
      'index': 0,
      'timestamp': '2023-10-01',
      'data': 'First block',
      'previous_hash': None,
      'hash': '8b1efa6ff6f8e3b34ac7661ba38f6a1f0c97d55b664f4febb8b25e2abbc39a0b'
    },
    {
      'index': 1,
      'timestamp': '2023-10-02',
      'data': 'Second block',
      'previous_hash': '8b1efa6ff6f8e3b34ac7661ba38f6a1f0c97d55b664f4febb8b25e2abbc39a0b',
      'hash': 'b1d6dd9eb5f9e7d9166b1c23d6bd760b0edf4c22f8d49f3a9d4ed91c4f54b8a3'
    }
  ], indent=2)
  assert create_blockchain([
      {'timestamp': '2023-10-01', 'data': 'First block'},
      {'timestamp': '2023-10-02', 'data': 'Second block'},
      {'timestamp': '2023-10-03', 'data': 'Third block'}
  ])==json.dumps([
    {
      'index': 0,
      'timestamp': '2023-10-01',
      'data': 'First block',
      'previous_hash': None,
      'hash': '8b1efa6ff6f8e3b34ac7661ba38f6a1f0c97d55b664f4febb8b25e2abbc39a0b'
    },
    {
      'index': 1,
      'timestamp': '2023-10-02',
      'data': 'Second block',
      'previous_hash': '8b1efa6ff6f8e3b34ac7661ba38f6a1f0c97d55b664f4febb8b25e2abbc39a0b',
      'hash': 'b1d6dd9eb5f9e7d9166b1c23d6bd760b0edf4c22f8d49f3a9d4ed91c4f54b8a3'
    },
    {
      'index': 2,
      'timestamp': '2023-10-03',
      'data': 'Third block',
      'previous_hash': 'b1d6dd9eb5f9e7d9166b1c23d6bd760b0edf4c22f8d49f3a9d4ed91c4f54b8a3',
      'hash': 'e5e075cb5fddcf1ab9b0cef79d7b3e0e1bd89f3c4e41f2d36f2b8a0f1f4b5e5f'
    }
  ], indent=2)
output: import hashlib
  import json
  
  def create_blockchain(blocks):
      if not blocks:
          return None
      
      blockchain = []
      
      for index, block in enumerate(blocks):
          block_data = {
              'index': index,
              'timestamp': block['timestamp'],
              'data': block['data'],
              'previous_hash': blockchain[-1]['hash'] if blockchain else None
          }
          block_data['hash'] = hashlib.sha256(json.dumps(block_data, sort_keys=True).encode()).hexdigest()
          blockchain.append(block_data)
      
      return json.dumps(blockchain, indent=2)