mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added an additional param to BinToHex so as to limit the size of the output
This commit is contained in:
parent
5ffb54929c
commit
9c391cb015
@ -54,9 +54,12 @@ std::string RsUtil::BinToHex(const std::string &bin)
|
||||
return BinToHex(bin.c_str(), bin.length());
|
||||
}
|
||||
|
||||
std::string RsUtil::BinToHex(const unsigned char *arr, const uint32_t len)
|
||||
std::string RsUtil::BinToHex(const unsigned char *arr, const uint32_t len,uint32_t max_len)
|
||||
{
|
||||
return BinToHex((char*)arr,len) ;
|
||||
if(max_len > 0)
|
||||
return BinToHex((char*)arr,std::min(max_len,len)) + ((len > max_len)?"...":"") ;
|
||||
else
|
||||
return BinToHex((char*)arr,len) ;
|
||||
}
|
||||
std::string RsUtil::BinToHex(const char *arr, const uint32_t len)
|
||||
{
|
||||
|
@ -36,7 +36,10 @@ namespace RsUtil {
|
||||
|
||||
std::string BinToHex(const std::string &bin);
|
||||
std::string BinToHex(const char *arr, const uint32_t len);
|
||||
std::string BinToHex(const unsigned char *arr, const uint32_t len);
|
||||
|
||||
// proxy function. When max_len>0 and len>max_len, only the first "max_len" bytes are writen to the string and "..." is happened.
|
||||
|
||||
std::string BinToHex(const unsigned char *arr, const uint32_t len, uint32_t max_len=0);
|
||||
std::string NumberToString(uint64_t n, bool hex=false);
|
||||
std::string HashId(const std::string &id, bool reverse = false);
|
||||
std::vector<uint8_t> BinToSha256(const std::vector<uint8_t> &in);
|
||||
|
Loading…
Reference in New Issue
Block a user