Krotos Modules 3
Loading...
Searching...
No Matches
SamplerUtils.h
Go to the documentation of this file.
1#pragma once
2// Version: 0.1
3// Date: 09/05/2023
4// Increment version & date when changed
5#define CRUMPETS \
6 std::string { "5128bd6c2bc42ed6835d9d24ee0e7200cc8aeae68e18e9f1ea3f6cd52cc082a8" }
7
8#define TEA \
9 std::string { "ff26827f8059e3866680c22a95a7f97358c5a02924c82ef53a7b1259d5d31637" }
10
11namespace krotos
12{
13 // Dummy class for content protection
15 {
16 public:
20 static std::string getSampleHash(const File& path)
21 {
22 auto pathHash = juce::MD5(path.getFullPathName().toUTF8()).toHexString();
23 auto nameHash = juce::MD5(path.getFileName().toUTF8()).toHexString();
24 return (pathHash + nameHash).toStdString();
25 }
26
30 static void getSampleMetadata(const std::string& input, unsigned char* byteArray)
31 {
32 for (size_t i = 0, j = 0; i < input.length(); i += 2, j++)
33 {
34 std::string byteStr = input.substr(i, 2);
35 unsigned int byteValue;
36 std::istringstream(byteStr) >> std::hex >> byteValue;
37 byteArray[j] = static_cast<unsigned char>(byteValue);
38 }
39 }
40
44 static bool verifySampleHash(const juce::String& hash, const juce::String& sample)
45 {
46 auto checksum = juce::MD5((hash + getInitData()).toUTF8()).toHexString();
47
48 auto metadataSum = juce::MD5((hash + TEA).toUTF8()).toHexString();
49
50 return metadataSum == sample;
51 }
52
53 static const juce::String& getInitData()
54 {
55 static const juce::String salt = "334647ab85deb0103d194556d290a4b8f17457939d3cb8b56793270c5ba4a4a5";
56 return salt;
57 }
58 };
59
60} // namespace krotos
#define TEA
Definition SamplerUtils.h:8
Definition SamplerUtils.h:15
static std::string getSampleHash(const File &path)
Definition SamplerUtils.h:20
static void getSampleMetadata(const std::string &input, unsigned char *byteArray)
Definition SamplerUtils.h:30
static const juce::String & getInitData()
Definition SamplerUtils.h:53
static bool verifySampleHash(const juce::String &hash, const juce::String &sample)
Definition SamplerUtils.h:44
Definition AirAbsorptionFilter.cpp:2