---
title: "Simple Anti-Tamper - s&box library"
description: "Keep your saves safe from tampering!"
canonical: "https://sbox.watch/zh-cn/libraries/quality/simpleantitamper/"
generated_at: "2026-11-27T13:30:25.246Z"
---

# Simple Anti-Tamper

Keep your saves safe from tampering!

- 类型: 库
- 标识符: quality.simpleantitamper
- 创作者: quality
- 规范地址: https://sbox.watch/zh-cn/libraries/quality/simpleantitamper/
- Markdown: https://sbox.watch/zh-cn/libraries/quality/simpleantitamper/index.md
- sbox.game: https://sbox.game/quality/simpleantitamper/
- 生成时间: 2026-11-27T13:30:25.246Z

## 统计

- 24小时热度: +0
- Terry 评分: 65%
- 收藏: 2
- 好评: 5
- 差评: 0
- 更新时间: 2026年6月3日
- 创建时间: 2026年2月16日
- 大小: 3.2 KB
- 文件: 5


## 描述

public class PlayerData
{
 public int Level { get; set; } // Will be serialized
 public int MaxHealth { get; set; } // Will be serialized
 public string Username; // Won't be serialized

 public static void Save( PlayerData data )
 {
 FileSystem.Data.WriteJson( "player.json", AntiTamper.Lock( data, 1254854 ) );
 }

 public static PlayerData Load()
 {
 return AntiTamper.Unlock(
 FileSystem.Data.ReadJson<LockedData>( "player.json" ),
 1254854,
 new PlayerData()
 );
 }
}
// later...
 try
 {
 data = PlayerData.Load();
 } catch
 {
 Log.Info( "Naughty cheater!" );
 data = new PlayerData();
 }This library serializes your struct as usual, then performs a hash on the string and a magic number you've provided.
When you load the save from the disk, the hash is checked before the object is accepted.

Pick a unique number for your project, but NEVER CHANGE IT! If you do, all old saves will be invalid.

Q: Are my saves actually safe from tampering?
A: Haha, no. This library prevents the most basic tampering where you literally just edit values in the json.
To bypass it, someone would have to open your game code and find the magic number you picked, then do annoying hash calculations themselves.

Sample project: https://nixx.is-fantabulo.us/antitamper.zip



## More by quality

| Package | 标识符 | 玩家 | 收藏 | 好评 | 评分 | Markdown |
| --- | --- | --- | --- | --- | --- | --- |
| Changelog Helper | quality.changeloghelper | 0 | 0 | 0 | -- | https://sbox.watch/zh-cn/libraries/quality/changeloghelper/index.md |
| Debug Assertions | quality.debugassertions | 0 | 0 | 0 | -- | https://sbox.watch/zh-cn/libraries/quality/debugassertions/index.md |
