code: func getStateByRangeAndDecrypt(stub shim.ChaincodeStubInterface, ent entities.Encrypter, startKey, endKey string) ([]byte, error) {
  	// we call get state by range to go through the entire range
  	iterator, err := stub.GetStateByRange(startKey, endKey)
  	if err != nil {
  		return nil, err
  	}
  	defer iterator.Close()
  
  	// we decrypt each entry - the assumption is that they have all been encrypted with the same key
  	keyvalueset := []keyValuePair{}
  	for iterator.HasNext() {
  		el, err := iterator.Next()
  		if err != nil {
  			return nil, err
  		}
  
  		v, err := ent.Decrypt(el.Value)
  		if err != nil {
  			return nil, err
  		}
  
  		keyvalueset = append(keyvalueset, keyValuePair{el.Key, string(v)})
  	}
  
  	bytes, err := json.Marshal(keyvalueset)
  	if err != nil {
  		return nil, err
  	}
  
  	return bytes, nil
  }
docs: // getStateByRangeAndDecrypt retrieves a range of KVS pairs from the
  // ledger and decrypts each value with the supplied entity; it returns
  // a json-marshalled slice of keyValuePair