-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyFileUtils.h
More file actions
56 lines (43 loc) · 1.52 KB
/
KeyFileUtils.h
File metadata and controls
56 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
==============================================================================
KeyFileUtils.h
Created: 23 Sep 2019 6:51:55pm
Author: Edwin Park
==============================================================================
*/
#pragma once
#include <juce_core/juce_core.h>
#include <juce_cryptography/juce_cryptography.h>
using juce::RSAKey;
using juce::String;
using juce::StringArray;
using juce::StringRef;
using juce::Time;
using juce::XmlElement;
struct KeyFileUtils {
public:
struct KeyFileData {
String user_name, user_email;
String product_id, product_version_range;
StringArray machine_ids;
bool keyFileExpires;
Time expiryTime;
};
static KeyFileData getDataFromKeyFile(XmlElement xml);
static XmlElement getXmlFromKeyFile(String keyFileText, RSAKey rsaPublicKey);
private:
// Get individual XML data elements
// ==============================================================================
static StringArray getMachineIDs(XmlElement xml, StringRef attributeName) {
StringArray numbers;
numbers.addTokens(xml.getStringAttribute(attributeName), ",; ",
StringRef());
numbers.trim();
numbers.removeEmptyStrings();
return numbers;
}
// crypto
// =======================================================================================
static String encryptXML(const XmlElement &xml, RSAKey privateKey);
static XmlElement decryptXML(String hexData, RSAKey rsaPublicKey);
};