NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
crypto.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #include "crypto.hpp"
23 #include "../encoding/buffer-stream.hpp"
24 
25 #include "../security/v1/cryptopp.hpp"
26 
27 namespace ndn {
28 namespace crypto {
29 
31 computeSha256Digest(const uint8_t* data, size_t dataLength)
32 {
33  try {
34  CryptoPP::SHA256 hash;
35  OBufferStream os;
36  CryptoPP::StringSource(data, dataLength, true,
37  new CryptoPP::HashFilter(hash, new CryptoPP::FileSink(os)));
38  return os.buf();
39  }
40  catch (CryptoPP::Exception& e) {
41  return ConstBufferPtr();
42  }
43 }
44 
45 } // namespace crypto
46 } // namespace ndn
Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< Buffer > buf()
Flush written data to the stream and return shared pointer to the underlying buffer.
ConstBufferPtr computeSha256Digest(const uint8_t *data, size_t dataLength)
Compute the sha-256 digest of data.
Definition: crypto.cpp:31
implements an output stream that constructs ndn::Buffer
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33