mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-19 18:45:52 +00:00
Add static has function to save a copy. Use <0 for 'whole object', not 0.
This commit is contained in:
@@ -125,22 +125,27 @@ std::vector<unsigned char> Serializer::getRaw(int offset, int length) const
|
||||
uint160 Serializer::getRIPEMD160(int size) const
|
||||
{
|
||||
uint160 ret;
|
||||
if((size==0)||(size>mData.size())) size=mData.size();
|
||||
if((size<0)||(size>mData.size())) size=mData.size();
|
||||
RIPEMD160(&(mData.front()), size, (unsigned char *) &ret);
|
||||
}
|
||||
|
||||
uint256 Serializer::getSHA256(int size) const
|
||||
{
|
||||
uint256 ret;
|
||||
if((size==0)||(size>mData.size())) size=mData.size();
|
||||
if((size<0)||(size>mData.size())) size=mData.size();
|
||||
SHA256(&(mData.front()), size, (unsigned char *) &ret);
|
||||
}
|
||||
|
||||
uint256 Serializer::getSHA512Half(int size) const
|
||||
{
|
||||
return getSHA512Half(mData, size);
|
||||
}
|
||||
|
||||
uint256 Serializer::getSHA512Half(const std::vector<unsigned char>& data, int size)
|
||||
{
|
||||
char buf[64];
|
||||
if((size==0)||(size>mData.size())) size=mData.size();
|
||||
SHA512(&(mData.front()), size, (unsigned char *) buf);
|
||||
if((size<0)||(size>data.size())) size=data.size();
|
||||
SHA512(&(data.front()), size, (unsigned char *) buf);
|
||||
return * (uint256 *) buf;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,10 @@ class Serializer
|
||||
std::vector<unsigned char> getRaw(int offset, int length) const;
|
||||
|
||||
// hash functions
|
||||
uint160 getRIPEMD160(int size=0) const;
|
||||
uint256 getSHA256(int size=0) const;
|
||||
uint256 getSHA512Half(int size=0) const;
|
||||
uint160 getRIPEMD160(int size=-1) const;
|
||||
uint256 getSHA256(int size=-1) const;
|
||||
uint256 getSHA512Half(int size=-1) const;
|
||||
static uint256 getSHA512Half(const std::vector<unsigned char>& data, int size=-1);
|
||||
|
||||
// totality functions
|
||||
int getLength() const { return mData.size(); }
|
||||
|
||||
Reference in New Issue
Block a user