Advertisement
Deozaan

Secure Int struct

Jan 7th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. /// <summary>A secure int which is hard to change using a program like Poke.</summary>
  2. struct secint {
  3.     //public int key { get { return _key; } }
  4.     public int value {
  5.         get { return _value ^ _key; }
  6.         set {
  7.             _key = rng.Next(0, int.MaxValue);
  8.             _value = value ^ _key;
  9.         }
  10.     }
  11.  
  12.     private System.Random rng;
  13.     private int _key;
  14.     private int _value;
  15.  
  16.     public secint(int val) {
  17.         rng = new System.Random();
  18.         _key = rng.Next(0, int.MaxValue);
  19.         _value = val ^ _key;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement