mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 22:17:17 +03:00
move to new cspot
This commit is contained in:
@@ -23,7 +23,20 @@ uint64_t hton64(uint64_t value) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string bytesToHexString(std::vector<uint8_t>& v) {
|
||||
std::vector<uint8_t> stringHexToBytes(const std::string & s) {
|
||||
std::vector<uint8_t> v;
|
||||
v.reserve(s.length() / 2);
|
||||
|
||||
for (std::string::size_type i = 0; i < s.length(); i += 2) {
|
||||
std::string byteString = s.substr(i, 2);
|
||||
uint8_t byte = (uint8_t) strtol(byteString.c_str(), NULL, 16);
|
||||
v.push_back(byte);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
std::string bytesToHexString(const std::vector<uint8_t>& v) {
|
||||
std::stringstream ss;
|
||||
ss << std::hex << std::setfill('0');
|
||||
std::vector<uint8_t>::const_iterator it;
|
||||
@@ -64,6 +77,28 @@ std::vector<uint8_t> bigNumAdd(std::vector<uint8_t> num, int n)
|
||||
return num;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> bigNumDivide(std::vector<uint8_t> num, int n)
|
||||
{
|
||||
auto carry = 0;
|
||||
for (int x = 0; x < num.size(); x++)
|
||||
{
|
||||
int res = num[x] + carry * 256;
|
||||
if (res < n)
|
||||
{
|
||||
carry = res;
|
||||
num[x] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Carry the rest of the division
|
||||
carry = res % n;
|
||||
num[x] = res / n;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> bigNumMultiply(std::vector<uint8_t> num, int n)
|
||||
{
|
||||
auto carry = 0;
|
||||
|
||||
Reference in New Issue
Block a user