Change wire encoding to return a Blob.
diff --git a/ndn-cpp/data.hpp b/ndn-cpp/data.hpp
index ad87674..bca4507 100644
--- a/ndn-cpp/data.hpp
+++ b/ndn-cpp/data.hpp
@@ -148,7 +148,7 @@
   {
   }
   
-  ptr_lib::shared_ptr<std::vector<unsigned char> > wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const 
+  Blob wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const 
   {
     return wireFormat.encodeData(*this);
   }
@@ -200,7 +200,15 @@
   { 
     content_ = Blob(content, contentLength); 
   }
-    
+      
+  /**
+   * Set content to point to an existing byte array.  IMPORTANT: After calling this,
+   * if you keep a pointer to the array then you must treat the array as immutable and promise not to change it.
+   * @param content A pointer to a vector with the byte array.  This takes another reference and does not copy the bytes.
+   */
+  void setContent(const ptr_lib::shared_ptr<std::vector<unsigned char> > &content) { content_ = content; }
+  void setContent(const ptr_lib::shared_ptr<const std::vector<unsigned char> > &content) { content_ = content; }
+
 private:
   Signature signature_;
   Name name_;
diff --git a/ndn-cpp/encoding/binary-xml-wire-format.cpp b/ndn-cpp/encoding/binary-xml-wire-format.cpp
index 2bb2093..39f7b4a 100644
--- a/ndn-cpp/encoding/binary-xml-wire-format.cpp
+++ b/ndn-cpp/encoding/binary-xml-wire-format.cpp
@@ -24,7 +24,7 @@
   return new BinaryXmlWireFormat();
 }
   
-ptr_lib::shared_ptr<vector<unsigned char> > BinaryXmlWireFormat::encodeInterest(const Interest& interest) 
+Blob BinaryXmlWireFormat::encodeInterest(const Interest& interest) 
 {
   struct ndn_NameComponent nameComponents[100];
   struct ndn_ExcludeEntry excludeEntries[100];
@@ -59,8 +59,7 @@
   interest.set(interestStruct);
 }
 
-ptr_lib::shared_ptr<vector<unsigned char> > BinaryXmlWireFormat::encodeData
-  (const Data& data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset) 
+Blob BinaryXmlWireFormat::encodeData(const Data& data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset) 
 {
   struct ndn_NameComponent nameComponents[100];
   struct ndn_NameComponent keyNameComponents[100];
@@ -96,7 +95,7 @@
   data.set(dataStruct);
 }
 
-ptr_lib::shared_ptr<vector<unsigned char> > BinaryXmlWireFormat::encodeForwardingEntry(const ForwardingEntry& forwardingEntry) 
+Blob BinaryXmlWireFormat::encodeForwardingEntry(const ForwardingEntry& forwardingEntry) 
 {
   struct ndn_NameComponent prefixNameComponents[100];
   struct ndn_ForwardingEntry forwardingEntryStruct;
diff --git a/ndn-cpp/encoding/binary-xml-wire-format.hpp b/ndn-cpp/encoding/binary-xml-wire-format.hpp
index aca140d..6647566 100644
--- a/ndn-cpp/encoding/binary-xml-wire-format.hpp
+++ b/ndn-cpp/encoding/binary-xml-wire-format.hpp
@@ -19,9 +19,9 @@
   /**
    * Encode interest in binary XML and return the encoding.
    * @param interest The Interest object to encode.
-   * @return A shared_ptr with the vector<unsigned char> containing the encoding.
+   * @return A Blob containing the encoding.
    */  
-  virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeInterest(const Interest& interest);
+  virtual Blob encodeInterest(const Interest& interest);
     
   /**
    * Decode input as an interest in binary XML and set the fields of the interest object.
@@ -38,9 +38,9 @@
    * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value.
    * @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed.
    * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value.
-   * @return A shared_ptr with the vector<unsigned char> containing the encoding.
+   * @return A Blob containing the encoding.
    */
-  virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeData
+  virtual Blob encodeData
     (const Data& data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset);
   
   /**
@@ -61,9 +61,9 @@
   /**
    * Encode forwardingEntry in binary XML and return the encoding. 
    * @param forwardingEntry The ForwardingEntry object to encode.
-   * @return A shared_ptr with the vector<unsigned char> containing the encoding.
+   * @return A Blob containing the encoding.
    */
-  virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeForwardingEntry(const ForwardingEntry& forwardingEntry);
+  virtual Blob encodeForwardingEntry(const ForwardingEntry& forwardingEntry);
   
   /**
    * Decode input as a forwarding entry in binary XML and set the fields of the forwardingEntry object. 
diff --git a/ndn-cpp/encoding/wire-format.cpp b/ndn-cpp/encoding/wire-format.cpp
index e0a4fc0..ced4c18 100644
--- a/ndn-cpp/encoding/wire-format.cpp
+++ b/ndn-cpp/encoding/wire-format.cpp
@@ -26,7 +26,7 @@
   return defaultWireFormat_;
 }
 
-ptr_lib::shared_ptr<vector<unsigned char> > WireFormat::encodeInterest(const Interest& interest) 
+Blob WireFormat::encodeInterest(const Interest& interest) 
 {
   throw logic_error("unimplemented");
 }
@@ -35,8 +35,7 @@
   throw logic_error("unimplemented");
 }
 
-ptr_lib::shared_ptr<vector<unsigned char> > WireFormat::encodeData
-  (const Data& data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset) 
+Blob WireFormat::encodeData(const Data& data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset) 
 {
   throw logic_error("unimplemented");
 }
@@ -46,7 +45,7 @@
   throw logic_error("unimplemented");
 }
 
-ptr_lib::shared_ptr<vector<unsigned char> > WireFormat::encodeForwardingEntry(const ForwardingEntry& forwardingEntry) 
+Blob WireFormat::encodeForwardingEntry(const ForwardingEntry& forwardingEntry) 
 {
   throw logic_error("unimplemented");
 }
diff --git a/ndn-cpp/encoding/wire-format.hpp b/ndn-cpp/encoding/wire-format.hpp
index b0b2ea4..575b441 100644
--- a/ndn-cpp/encoding/wire-format.hpp
+++ b/ndn-cpp/encoding/wire-format.hpp
@@ -7,7 +7,7 @@
 #define NDN_WIREFORMAT_HPP
 
 #include "../common.hpp"
-#include <vector>
+#include "../util/blob.hpp"
 
 namespace ndn {
   
@@ -20,10 +20,10 @@
   /**
    * Encode interest and return the encoding.  Your derived class should override.
    * @param interest The Interest object to encode.
-   * @return A shared_ptr with the vector<unsigned char> containing the encoding.
+   * @return A Blob containing the encoding.
    * @throw logic_error for unimplemented if the derived class does not override.
    */
-  virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeInterest(const Interest& interest);
+  virtual Blob encodeInterest(const Interest& interest);
   
   /**
    * Decode input as an interest and set the fields of the interest object.  Your derived class should override.
@@ -41,19 +41,19 @@
    * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value.
    * @param signedFieldsEndOffset Return the offset in the encoding of the end of the fields which are signed.
    * If you are not encoding in order to sign, you can call encodeData(const Data& data) to ignore this returned value.
-   * @return A shared_ptr with the vector<unsigned char> containing the encoding.
+   * @return A Blob containing the encoding.
    * @throw logic_error for unimplemented if the derived class does not override.
    */
-  virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeData
+  virtual Blob encodeData
     (const Data& data, unsigned int *signedFieldsBeginOffset, unsigned int *signedFieldsEndOffset);
 
   /**
    * Encode data and return the encoding.
    * @param data The Data object to encode.
-   * @return A shared_ptr with the vector<unsigned char> containing the encoding.
+   * @return A Blob containing the encoding.
    * @throw logic_error for unimplemented if the derived class does not override.
    */
-  ptr_lib::shared_ptr<std::vector<unsigned char> > encodeData(const Data& data)
+  Blob encodeData(const Data& data)
   {
     unsigned int dummyBeginOffset, dummyEndOffset;
     return encodeData(data, &dummyBeginOffset, &dummyEndOffset);
@@ -84,10 +84,10 @@
   /**
    * Encode forwardingEntry and return the encoding.  Your derived class should override.
    * @param forwardingEntry The ForwardingEntry object to encode.
-   * @return A shared_ptr with the vector<unsigned char> containing the encoding.
+   * @return A Blob containing the encoding.
    * @throw logic_error for unimplemented if the derived class does not override.
    */
-  virtual ptr_lib::shared_ptr<std::vector<unsigned char> > encodeForwardingEntry(const ForwardingEntry& forwardingEntry);
+  virtual Blob encodeForwardingEntry(const ForwardingEntry& forwardingEntry);
   
   /**
    * Decode input as a forwarding entry and set the fields of the forwardingEntry object.  Your derived class should override.
diff --git a/ndn-cpp/forwarding-entry.hpp b/ndn-cpp/forwarding-entry.hpp
index 9919f49..177e5c4 100644
--- a/ndn-cpp/forwarding-entry.hpp
+++ b/ndn-cpp/forwarding-entry.hpp
@@ -31,30 +31,18 @@
   {
   }
   
-  ptr_lib::shared_ptr<std::vector<unsigned char> > wireEncode(WireFormat& wireFormat) const 
+  Blob wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const 
   {
     return wireFormat.encodeForwardingEntry(*this);
   }
-  ptr_lib::shared_ptr<std::vector<unsigned char> > wireEncode() const 
-  {
-    return wireEncode(*WireFormat::getDefaultWireFormat());
-  }
-  void wireDecode(const unsigned char *input, unsigned int inputLength, WireFormat& wireFormat) 
+  void wireDecode(const unsigned char *input, unsigned int inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) 
   {
     wireFormat.decodeForwardingEntry(*this, input, inputLength);
   }
-  void wireDecode(const unsigned char *input, unsigned int inputLength) 
-  {
-    wireDecode(input, inputLength, *WireFormat::getDefaultWireFormat());
-  }
-  void wireDecode(const std::vector<unsigned char>& input, WireFormat& wireFormat) 
+  void wireDecode(const std::vector<unsigned char>& input, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) 
   {
     wireDecode(&input[0], input.size(), wireFormat);
   }
-  void wireDecode(const std::vector<unsigned char>& input) 
-  {
-    wireDecode(&input[0], input.size());
-  }
   
   /**
    * Set the forwardingEntryStruct to point to the components in this forwarding entry, without copying any memory.
diff --git a/ndn-cpp/interest.hpp b/ndn-cpp/interest.hpp
index 50baaa4..bd7991f 100644
--- a/ndn-cpp/interest.hpp
+++ b/ndn-cpp/interest.hpp
@@ -159,7 +159,7 @@
     construct();
   }
   
-  ptr_lib::shared_ptr<std::vector<unsigned char> > wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const 
+  Blob wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const 
   {
     return wireFormat.encodeInterest(*this);
   }
diff --git a/ndn-cpp/key.hpp b/ndn-cpp/key.hpp
index 9f4f30e..b28cd33 100644
--- a/ndn-cpp/key.hpp
+++ b/ndn-cpp/key.hpp
@@ -60,7 +60,7 @@
   }
   
   /**
-   * Set keyData to point to an existing byte array.  IMPORTANT: After calling this constructor,
+   * Set keyData to point to an existing byte array.  IMPORTANT: After calling this,
    * if you keep a pointer to the array then you must treat the array as immutable and promise not to change it.
    * @param keyData A pointer to a vector with the byte array.  This takes another reference and does not copy the bytes.
    */
diff --git a/ndn-cpp/node.cpp b/ndn-cpp/node.cpp
index 7fb34fd..2170fe9 100644
--- a/ndn-cpp/node.cpp
+++ b/ndn-cpp/node.cpp
@@ -37,7 +37,7 @@
   
   pit_.push_back(shared_ptr<PitEntry>(new PitEntry(shared_ptr<const Interest>(new Interest(interest)), onData, onTimeout)));
   
-  shared_ptr<vector<unsigned char> > encoding = interest.wireEncode();  
+  Blob encoding = interest.wireEncode();  
   transport_->send(*encoding);
 }
 
@@ -73,15 +73,15 @@
 {
   // Create a ForwardingEntry.
   ForwardingEntry forwardingEntry("selfreg", prefix, PublisherPublicKeyDigest(), -1, 3, 2147483647);
-  ptr_lib::shared_ptr<vector<unsigned char> > content = forwardingEntry.wireEncode();
+  Blob content = forwardingEntry.wireEncode();
 
   // Set the ForwardingEntry as the content of a Data packet and sign.
   Data data;
-  data.setContent(*content);
+  data.setContent(content);
   data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
   // TODO: Should we sign with a different key?
   KeyChain::defaultSign(data);
-  ptr_lib::shared_ptr<vector<unsigned char> > encodedData = data.wireEncode();
+  Blob encodedData = data.wireEncode();
   
   // Create an interest where the name has the encoded Data packet.
   Name interestName;
@@ -90,11 +90,11 @@
   interestName.addComponent(component0, sizeof(component0) - 1);
   interestName.addComponent(ndndId_);
   interestName.addComponent(component2, sizeof(component2) - 1);
-  interestName.addComponent(*encodedData);
+  interestName.addComponent(encodedData);
   
   Interest interest(interestName);
   interest.setScope(1);
-  ptr_lib::shared_ptr<vector<unsigned char> > encodedInterest = interest.wireEncode();
+  Blob encodedInterest = interest.wireEncode();
   
   // Save the onInterest callback and send the registration interest.
   registeredPrefixTable_.push_back(shared_ptr<PrefixEntry>(new PrefixEntry(shared_ptr<const Name>(new Name(prefix)), onInterest)));
diff --git a/ndn-cpp/security/key-chain.cpp b/ndn-cpp/security/key-chain.cpp
index 5ba46ba..ba36071 100644
--- a/ndn-cpp/security/key-chain.cpp
+++ b/ndn-cpp/security/key-chain.cpp
@@ -67,9 +67,9 @@
 static void digestDataFieldsSha256(const Data& data, WireFormat& wireFormat, unsigned char *digest)
 {
   unsigned int signedFieldsBeginOffset, signedFieldsEndOffset;
-  ptr_lib::shared_ptr<vector<unsigned char> > encoding = wireFormat.encodeData(data, &signedFieldsBeginOffset, &signedFieldsEndOffset);
+  Blob encoding = wireFormat.encodeData(data, &signedFieldsBeginOffset, &signedFieldsEndOffset);
   
-  ndn_digestSha256(&encoding->front() + signedFieldsBeginOffset, signedFieldsEndOffset - signedFieldsBeginOffset, digest);
+  ndn_digestSha256(encoding.buf() + signedFieldsBeginOffset, signedFieldsEndOffset - signedFieldsBeginOffset, digest);
 }
 
 void KeyChain::sign
diff --git a/tests/test-encode-decode-data.cpp b/tests/test-encode-decode-data.cpp
index 1e4c165..616b4b0 100644
--- a/tests/test-encode-decode-data.cpp
+++ b/tests/test-encode-decode-data.cpp
@@ -155,7 +155,7 @@
     dumpData(data);
     cout << "Decoded Data signature verification: " << (KeyChain::selfVerifyData(Data1, sizeof(Data1)) ? "VERIFIED" : "FAILED") << endl;
     
-    ptr_lib::shared_ptr<vector<unsigned char> > encoding = data.wireEncode();
+    Blob encoding = data.wireEncode();
     
     Data reDecodedData;
     reDecodedData.wireDecode(*encoding);
@@ -171,7 +171,7 @@
     KeyChain::defaultSign(freshData);
     cout << endl << "Freshly-signed Data:" << endl;
     dumpData(freshData);
-    ptr_lib::shared_ptr<vector<unsigned char> > freshEncoding = freshData.wireEncode();
+    Blob freshEncoding = freshData.wireEncode();
     cout << "Freshly-signed Data signature verification: " << (KeyChain::selfVerifyData(&freshEncoding->front(), freshEncoding->size()) ? "VERIFIED" : "FAILED") << endl;
   } catch (exception& e) {
     cout << "exception: " << e.what() << endl;
diff --git a/tests/test-encode-decode-forwarding-entry.cpp b/tests/test-encode-decode-forwarding-entry.cpp
index dfa780e..1ee801a 100644
--- a/tests/test-encode-decode-forwarding-entry.cpp
+++ b/tests/test-encode-decode-forwarding-entry.cpp
@@ -59,6 +59,9 @@
 
 static inline string toString(const vector<unsigned char>& v)
 {
+  if (!&v)
+    return "";
+  
   return string(&v[0], &v[0] + v.size());
 }
 
@@ -67,7 +70,7 @@
   cout << "action: " << forwardingEntry.getAction() << endl;
   cout << "prefix: " << forwardingEntry.getPrefix().to_uri() << endl;
   cout << "publisherPublicKeyDigest: " 
-       << (forwardingEntry.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0 ? toHex(forwardingEntry.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()) : "<none>") << endl;
+       << (forwardingEntry.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0 ? toHex(*forwardingEntry.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()) : "<none>") << endl;
   cout << "faceId: ";
   if (forwardingEntry.getFaceId() >= 0)
     cout << forwardingEntry.getFaceId() << endl;
@@ -101,16 +104,16 @@
     cout << interest.getScope() << endl;
   else
     cout << "<none>" << endl;
-  cout << "name[0]: " << toString(interest.getName().getComponent(0).getValue()) << endl;
-  cout << "name[1]: " << toHex(interest.getName().getComponent(1).getValue()) << endl;
-  cout << "name[2]: " << toString(interest.getName().getComponent(2).getValue()) << endl;
+  cout << "name[0]: " << toString(*interest.getName().getComponent(0).getValue()) << endl;
+  cout << "name[1]: " << toHex(*interest.getName().getComponent(1).getValue()) << endl;
+  cout << "name[2]: " << toString(*interest.getName().getComponent(2).getValue()) << endl;
   cout << "name[3] decoded as Data, showing content as ForwardingEntry: " << endl;
   
   Data data;
-  data.wireDecode(interest.getName().getComponent(3).getValue());
+  data.wireDecode(*interest.getName().getComponent(3).getValue());
   
   ForwardingEntry forwardingEntry;
-  forwardingEntry.wireDecode(data.getContent());
+  forwardingEntry.wireDecode(*data.getContent());
   dumpForwardingEntry(forwardingEntry);
 }
 
@@ -122,7 +125,7 @@
     cout << "Interest:" << endl;
     dumpInterestWithForwardingEntry(interest);
     
-    ptr_lib::shared_ptr<vector<unsigned char> > encoding = interest.wireEncode();
+    Blob encoding = interest.wireEncode();
     cout << endl << "Re-encoded interest " << toHex(*encoding) << endl;
 
     Interest reDecodedInterest;
diff --git a/tests/test-encode-decode-interest.cpp b/tests/test-encode-decode-interest.cpp
index ad638ce..9326893 100644
--- a/tests/test-encode-decode-interest.cpp
+++ b/tests/test-encode-decode-interest.cpp
@@ -44,7 +44,7 @@
   else
     cout << "<none>" << endl;
   cout << "publisherPublicKeyDigest: " 
-       << (interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0 ? toHex(interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()) : "<none>") << endl;
+       << (interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0 ? toHex(*interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()) : "<none>") << endl;
   cout << "exclude: " 
        << (interest.getExclude().getEntryCount() > 0 ? interest.getExclude().toUri() : "<none>") << endl;
   cout << "lifetimeMilliseconds: ";
@@ -79,7 +79,7 @@
     cout << "Interest:" << endl;
     dumpInterest(interest);
     
-    ptr_lib::shared_ptr<vector<unsigned char> > encoding = interest.wireEncode();
+    Blob encoding = interest.wireEncode();
     cout << endl << "Re-encoded interest " << toHex(*encoding) << endl;
 
     Interest reDecodedInterest;
diff --git a/tests/test-get-async.cpp b/tests/test-get-async.cpp
index 3c55b31..7c92997 100644
--- a/tests/test-get-async.cpp
+++ b/tests/test-get-async.cpp
@@ -29,7 +29,7 @@
     ++callbackCount_;
     cout << "Got data packet with name " << data->getName().to_uri() << endl;
     for (unsigned int i = 0; i < data->getContent().size(); ++i)
-      cout << data->getContent()[i];
+      cout << (*data->getContent())[i];
     cout << endl;  
   }
 
diff --git a/tests/test-publish-async.cpp b/tests/test-publish-async.cpp
index 49129c8..87fad40 100644
--- a/tests/test-publish-async.cpp
+++ b/tests/test-publish-async.cpp
@@ -32,7 +32,7 @@
     data.setContent((const unsigned char *)&content[0], content.size());
     data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
     KeyChain::defaultSign(data);
-    shared_ptr<vector<unsigned char> > encodedData = data.wireEncode();
+    Blob encodedData = data.wireEncode();
 
     cout << "Sent content " << content << endl;
     transport.send(*encodedData);