Skip to content

Instantly share code, notes, and snippets.

@ChunChunMorning
Last active December 11, 2015 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChunChunMorning/81635c17d3547a11596d to your computer and use it in GitHub Desktop.
Save ChunChunMorning/81635c17d3547a11596d to your computer and use it in GitHub Desktop.
Siv3Dの機能をフル活用してセーブデータを実装する No2
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