我怎样才能使游戏的保存文件以某种形式编码?

问题描述 投票:0回答:1

我想为我的游戏做一个保存。 (这不仅仅是一种保存硬币和东西的保存方式,它还保存了所选角色等。)但奶酪和重写以及用它做任何你想做的事情太容易了。

我希望用户更改保存文件中的内容不那么容易。

我的第一个想法是将其解码并编码为 base64,但它仍然太容易破解了。

如果有人问保存文件在技术上是一个重命名为 save.dat 的 txt 文件,这只是出于组织原因。

lua save love2d
1个回答
0
投票

自己写一个混淆器或者使用我简单的rot.lua ...

> _VERSION
Lua 5.4
> io.open('lua/rot.lua'):read('*a')
-- rot.lua
local rotator = function(...)
local args, rot, c = {...}, {}, ''

for i = 1, 63 do rot[c.char(i)] = c.char(i + 64) end
for i = 64, 128 do rot[c.char(i)] = c.char(i - 64) end

return(args[1]:gsub('.', rot))
end

return rotator

> getmetatable('').__index.rot = require('lua.rot')
> -- Create some Text
> save=[[I want to make a save for my game. (It's not just a kind of save that saves coins and stuff it's saves the selected character and etc.) But it's too easy to cheese and rewrite and do everything you want with it.
>> I want it to be less easy for the user to change things in the save file.
>> My first idea was to decode and encode it to base64 but it was still way too easy to crack.
>> If somebody would ask the save file is technically a txt file renamed to save.dat which is just for organization reasons.]]
> return(save) -- Shows it
I want to make a save for my game. (It's not just a kind of save that saves coins and stuff it's saves the selected character and etc.) But it's too easy to cheese and rewrite and do everything you want with it.
I want it to be less easy for the user to change things in the save file.
My first idea was to decode and encode it to base64 but it was still way too easy to crack.
If somebody would ask the save file is technically a txt file renamed to save.dat which is just for organization reasons.
> save = save:rot() -- Obfuscate it
> return(save) -- Show it
    `7!.4`4/`-!+%`!`3!6%`&/2`-9`'!-%n`h 4g3`./4`*534`!`+).$`/&`3!6%`4(!4`3!6%3`#/).3`!.$`345&&`)4g3`3!6%3`4(%`3%,%#4%$`#(!2!#4%2`!.$`%4#ni`54`)4g3`4//`%!39`4/`#(%%3%`!.$`2%72)4%`!.$`9`&)234`)$%!`7!3`4/`$%#/$%`!.$`%.#/$%`)4`4/`"!3%vt`"54`)4`7!3`34),,`7!9`4//`%!39`4/`#2!#+nJ.'3`)&`3/-%"/$9`7/5,$`!3+`4(%`3!6%`&),%`)3`4%#(.)#!,,9`!`484`&),%`2%.!-%$`4/`3!6%n$!4`7()#(`)3`*534`&/2`/2'!.):!4)/.`2%!3/.3n
> save = save:rot() -- Deobfuscate it
> return(save) -- Show it
I want to make a save for my game. (It's not just a kind of save that saves coins and stuff it's saves the selected character and etc.) But it's too easy to cheese and rewrite and do everything you want with it.
I want it to be less easy for the user to change things in the save file.
My first idea was to decode and encode it to base64 but it was still way too easy to crack.
If somebody would ask the save file is technically a txt file renamed to save.dat which is just for organization reasons.
© www.soinside.com 2019 - 2024. All rights reserved.