本文整理汇总了C++中Blob::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Blob::data方法的具体用法?C++ Blob::data怎么用?C++ Blob::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accountPrivateSign
Blob RippleAddress::accountPrivateSign (Blob const& message) const
{
if (vchData.size() == 33 && vchData[0] == 0xED)
{
uint8_t const* secretKey = &vchData[1];
ed25519_public_key publicKey;
Blob signature (sizeof (ed25519_signature));
ed25519_publickey (secretKey, publicKey);
ed25519_sign (
message.data(), message.size(), secretKey, publicKey,
&signature[0]);
assert (isCanonicalEd25519Signature (signature.data()));
return signature;
}
Blob result = ECDSASign(
sha512Half(makeSlice(message)), getAccountPrivate());
bool const ok = !result.empty();
CondLog (!ok, lsWARNING, RippleAddress)
<< "accountPrivateSign: Signing failed.";
return result;
}
示例2:
bool
PublicKey::checkSignature(const Blob& data, const Blob& signature) const {
if (!pk)
return false;
const gnutls_datum_t sig {(uint8_t*)signature.data(), (unsigned)signature.size()};
const gnutls_datum_t dat {(uint8_t*)data.data(), (unsigned)data.size()};
int rc = gnutls_pubkey_verify_data2(pk, GNUTLS_SIGN_RSA_SHA512, 0, &dat, &sig);
return rc >= 0;
}
示例3: Export
Blob CngKey::Export(CngKeyBlobFormat format) const {
EVP_PKEY* key = ToKey(_self);
Blob r;
int size;
byte *buf;
switch (format) {
case CngKeyBlobFormat::OSslEccPrivateBlob:
SslCheck((size = ::i2d_PrivateKey(key, 0)) >= 0);
r.Size = size;
SslCheck(::i2d_PrivateKey(key, &(buf = r.data())) == size);
break;
case CngKeyBlobFormat::OSslEccPrivateBignum:
{
const BIGNUM *bn = ::EC_KEY_get0_private_key(key->pkey.ec);
SslCheck(bn);
r.Size = BN_num_bytes(bn);
if (::BN_bn2bin(bn, r.data()) != r.Size)
Throw(E_FAIL);
}
break;
case CngKeyBlobFormat::OSslEccPublicBlob:
// SslCheck(size = ::i2o_ECPublicKey(key, 0));
SslCheck((size = ::i2d_PublicKey(key, 0)) >= 0);
r.Size = size;
// SslCheck(::i2o_ECPublicKey(key, &(buf = r.data())) == size);
SslCheck(::i2d_PublicKey(key, &(buf = r.data())) == size);
break;
case CngKeyBlobFormat::OSslEccPublicCompressedBlob:
{
CngKey tmp = _self;
key = ToKey(tmp);
::EC_KEY_set_conv_form(key->pkey.ec, POINT_CONVERSION_COMPRESSED);
r = tmp.Export(CngKeyBlobFormat::OSslEccPublicBlob);
}
break;
case CngKeyBlobFormat::OSslEccPublicUncompressedBlob:
{
CngKey tmp = _self;
key = ToKey(tmp);
::EC_KEY_set_conv_form(key->pkey.ec, POINT_CONVERSION_UNCOMPRESSED);
r = tmp.Export(CngKeyBlobFormat::OSslEccPublicBlob);
}
break;
case CngKeyBlobFormat::OSslEccPrivateCompressedBlob:
{
CngKey tmp = _self;
key = ToKey(tmp);
::EC_KEY_set_conv_form(key->pkey.ec, POINT_CONVERSION_COMPRESSED);
r = tmp.Export(CngKeyBlobFormat::OSslEccPrivateBlob);
}
break;
default:
Throw(E_INVALIDARG);
}
return r;
}
示例4: SetData
void Blob::SetData(Blob &source) {
if (data_)
data_ = nullptr;
shape_ = source.shape();
count_ = num() * channels() * height() * width();
data_ = source.data();
}
示例5: getOpenCVMat
Mat* MyImage::getOpenCVMat(){
if(mat == NULL) {
try {
Mat orig;
getMagickImage();
magick.magick("BGR");
Blob blb ;
magick.write(&blb);
mat = new Mat();
orig = Mat(magick.size().height(),
magick.size().width(),
CV_8UC3,
(void *) blb.data());
cvtColor(orig, *mat, CV_RGB2HSV);
magick.magick("RGB");
}
catch (Magick::Exception &e)
{
cout << "Caught a magick exception: " << e.what() << endl;
throw e;
}
}
return mat;
}
示例6:
Blob::Blob(const Blob &source) {
if (data_)
data_ = nullptr;
shape_ = source.shape();
count_ = source.count();
data_ = source.data();
}
示例7: setBlob
void PreparedStatement::setBlob(int column, const Blob &value)
{
locker l(d->mutex);
if (!d->prepared) {
return;
}
sqlite3_bind_blob(d->stmt, column, value.data(), value.size(), SQLITE_STATIC);
}
示例8: setBlob
void setBlob(MYSQL_BIND& bind, unsigned long& length, const Blob& data)
{
length = data.size();
reserve(bind, length);
memcpy(static_cast<char*>(bind.buffer), data.data(), length);
bind.buffer_type = MYSQL_TYPE_VAR_STRING;
bind.is_null = 0;
bind.length = &length;
}
示例9: verifySignature
bool RippleAddress::verifySignature(uint256 const& hash, Blob const& vchSig) const
{
if (vchData.size() != crypto_sign_PUBLICKEYBYTES
|| vchSig.size () != crypto_sign_BYTES)
throw std::runtime_error("bad inputs to verifySignature");
bool verified = crypto_sign_verify_detached(vchSig.data(),
hash.data(), hash.bytes, vchData.data()) == 0;
bool canonical = signatureIsCanonical (vchSig);
return verified && canonical;
}
示例10:
static
uint160 Hash160 (Blob const& vch)
{
uint256 hash1;
SHA256 (vch.data (), vch.size (), hash1.data ());
uint160 hash2;
RIPEMD160 (hash1.data (), hash1.size (), hash2.data ());
return hash2;
}
示例11: CryptoException
Blob
PrivateKey::sign(const Blob& data) const
{
if (!key)
throw CryptoException("Can't sign data: no private key set !");
gnutls_datum_t sig;
const gnutls_datum_t dat {(unsigned char*)data.data(), (unsigned)data.size()};
if (gnutls_privkey_sign_data(key, GNUTLS_DIG_SHA512, 0, &dat, &sig) != GNUTLS_E_SUCCESS)
throw CryptoException("Can't sign data !");
Blob ret(sig.data, sig.data+sig.size);
gnutls_free(sig.data);
return ret;
}
示例12: prepare
void prepare(svector<iovec>& v, void* ptr, const int sender=-1) {
Task<Image> * task = (Task<Image> *) ptr;
Blob* blob = task->getBlob();
task->get()->magick("BMP");
task->get()->write(blob);
struct iovec iov={const_cast<void*>(blob->data()),blob->length()};
v.push_back(iov);
setCallbackArg(ptr);
const char * imagename = task->name().c_str();
struct iovec iov2={const_cast<char*>(imagename),strlen(imagename)+1};
v.push_back(iov2);
setCallbackArg(nullptr);
}
示例13:
bool Base58::decodeWithCheck (const char* psz, Blob& vchRet, Alphabet const& alphabet)
{
if (!decode (psz, vchRet, alphabet))
return false;
auto size = vchRet.size ();
if (size < 4)
{
vchRet.clear ();
return false;
}
uint256 hash = SHA256Hash (vchRet.data (), vchRet.data () + size - 4);
if (memcmp (&hash, &vchRet.end ()[-4], 4) != 0)
{
vchRet.clear ();
return false;
}
vchRet.resize (size - 4);
return true;
}
示例14: fromString
// create from a base58 encoded seed
bool PaysharesPrivateKey::fromString(std::string& base58seed)
{
Blob vchTemp;
Base58::decodeWithCheck(base58seed.c_str(), vchTemp, Base58::getRippleAlphabet());
if (vchTemp.empty() &&
vchTemp.size() == crypto_sign_SEEDBYTES + 1 &&
vchTemp[0] == RippleAddress::VER_SEED)
{
return(false);
}
mSeed.resize(crypto_sign_SEEDBYTES);
memcpy(&mSeed[0], vchTemp.data() + 1, crypto_sign_SEEDBYTES);
mPair.setSeed(mSeed);
return(true);
}
示例15: createObject
NodeObject::Ptr DecodedBlob::createObject ()
{
bassert (m_success);
NodeObject::Ptr object;
if (m_success)
{
Blob data (m_dataBytes);
memcpy (data.data (), m_objectData, m_dataBytes);
object = NodeObject::createObject (
m_objectType, m_ledgerIndex, data, uint256::fromVoid (m_key));
}
return object;
}