-
Notifications
You must be signed in to change notification settings - Fork 1
/
CryptoKit.cpp
39 lines (30 loc) · 748 Bytes
/
CryptoKit.cpp
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
//
// CryptoKit.cpp
// Maw Kit
//
// Created by Lluís Ulzurrun de Asanza Sàez on 18/02/16.
//
//
#include "CryptoKit.hpp"
#include "Device.hpp"
namespace MK {
namespace CryptoKit {
const std::string symmetricEncrypt( const std::string &content )
{
std::string encrypted = std::string( content );
// Encryption key should be at least as long as message to be encrypted.
std::string key = MK::Device::UUID();
while ( key.size() < encrypted.size() ) {
key += MK::Device::UUID();
}
for ( int i = 0; i < encrypted.size(); i++ ) {
encrypted[i] ^= key[i];
}
return encrypted;
}
const std::string symmetricDecrypt( const std::string &content )
{
return symmetricEncrypt( content );
}
}; // namespace CryptoKit
}; // namespace MK