Last active
December 11, 2015 06:26
-
-
Save ChunChunMorning/81635c17d3547a11596d to your computer and use it in GitHub Desktop.
Siv3Dの機能をフル活用してセーブデータを実装する No2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool save(const FilePath& filePath) | |
{ | |
String data = L""; | |
for (auto content : m_data) | |
{ | |
data += m_delimiter + content.first + m_delimiter + content.second; | |
} | |
const MemoryReader encrypted = Crypto::EncryptString(data, m_aes128Key); | |
encrypted.save(filePath); | |
} | |
bool load(const FilePath& filePath) | |
{ | |
BinaryReader reader(filePath); | |
String data; | |
Crypto::DecryptString(reader.readWhole(), data, m_aes128Key); | |
auto contents = data.substr(1).split(data[0]); | |
for (size_t i = 0; i < contents.size(); i += 2) | |
{ | |
m_data[contents[i]] = contents[i + 1]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment