Last active
August 29, 2015 14:13
-
-
Save trzecieu/f422f8f63fd3d69a5432 to your computer and use it in GitHub Desktop.
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
package pl.asria.tools.data.secure { | |
public class sInt | |
{ | |
protected var _lifespan:int; | |
protected var _counter:int; | |
protected var _value:int; | |
protected var _lock:int; | |
public function sIntR(val:int = 0, lifespan:int = 16) | |
{ | |
_lifespan = lifespan; | |
_counter = _lifespan; | |
_lock = Math.random() * int.MAX_VALUE; | |
value = val; | |
} | |
public function get value():int | |
{ | |
return _lock ^ _value; | |
} | |
public function set value(value:int):void | |
{ | |
if (--_counter == 0) | |
{ | |
_lock = Math.random(); | |
_counter = _lifespan; | |
} | |
_value = value ^ _lock; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment