示例#1
0
        public static void SaveProtectedString(string name, string value)
        {
            byte[] entropy = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };

            byte[] enc = ProtectedData.Protect(Encoding.Unicode.GetBytes(value), entropy, DataProtectionScope.LocalMachine);

            byte[] dec = ProtectedData.Unprotect(enc, entropy, DataProtectionScope.CurrentUser);

            DataPrefs.SaveByteArray(name + "_Protected", dec, Mode.Overwrite);

            using (StreamWriter sw = new StreamWriter(Application.dataPath + "/" + DataPrefs.FolderName + "/" + name + DataPrefs.FileType)) {
                sw.WriteLine(BitConverter.ToString(enc));
            }
        }
示例#2
0
 public static byte Byte(string name, byte value, Mode m = 0)
 {
     DataPrefs.SaveByte(name, value);
     return(DataPrefs.LoadByte(name));
 }
示例#3
0
 public static byte[] ByteArray(string name, byte[] value, Mode m = 0)
 {
     DataPrefs.SaveByteArray(name, value, m);
     return(DataPrefs.LoadByteArray(name));
 }
示例#4
0
 public static uint Uint(string name, uint value, Mode m = 0)
 {
     DataPrefs.SaveUint(name, value, m);
     return(DataPrefs.LoadUint(name));
 }
示例#5
0
 public static double Double(string name, double value, Mode m = 0)
 {
     DataPrefs.SaveDouble(name, value, m);
     return(DataPrefs.LoadDouble(name));
 }
示例#6
0
 public static double[] DoubleArray(string name, double[] value, Mode n = 0)
 {
     DataPrefs.SaveDoubleArray(name, value, n);
     return(DataPrefs.LoadDoubleArray(name));
 }
示例#7
0
 public static string LoadProtectedString(string name)
 {
     return(Encoding.Unicode.GetString(DataPrefs.LoadByteArray(name + "_Protected")));
 }
示例#8
0
 public static sbyte Sbyte(string name, sbyte value, Mode m = 0)
 {
     DataPrefs.SaveSbyte(name, value, m);
     return(DataPrefs.LoadSbyte(name));
 }
示例#9
0
 public static float Float(string name, float value, Mode m = 0)
 {
     DataPrefs.SaveFloat(name, value, m);
     return(DataPrefs.LoadFloat(name));
 }
示例#10
0
 public static float[] FloatArray(string name, float[] value, Mode m = 0)
 {
     DataPrefs.SaveFloatArray(name, value, m);
     return(DataPrefs.LoadFloatArray(name));
 }
示例#11
0
 public static int Int(string name, int value, Mode m = 0)
 {
     DataPrefs.SaveInt(name, value, m);
     return(DataPrefs.LoadInt(name));
 }
示例#12
0
 public static int[] IntArray(string name, int[] value, Mode m = 0)
 {
     DataPrefs.SaveIntArray(name, value, m);
     return(DataPrefs.LoadIntArray(name));
 }
示例#13
0
 public static byte LoadProtectedByte(string name)
 {
     return(Convert.ToByte(Encoding.Unicode.GetString(DataPrefs.LoadByteArray(name + "_Protected"))));
 }
示例#14
0
 public static float LoadProtectedFloat(string name)
 {
     return(Convert.ToSingle(Encoding.Unicode.GetString(DataPrefs.LoadByteArray(name + "_Protected"))));
 }
示例#15
0
 public static int LoadProtectedInt(string name)
 {
     return(Convert.ToInt32(Encoding.Unicode.GetString(DataPrefs.LoadByteArray(name + "_Protected"))));
 }
示例#16
0
 public static bool[] BoolArray(string name, bool[] value, Mode m = 0)
 {
     DataPrefs.SaveBoolArray(name, value, m);
     return(DataPrefs.LoadBoolArray(name));
 }
示例#17
0
 public static bool Bool(string name, bool value, Mode m = 0)
 {
     DataPrefs.SaveBool(name, value, m);
     return(DataPrefs.LoadBool(name));
 }
示例#18
0
 public static string[] StringArray(string name, string[] value, Mode m = 0)
 {
     DataPrefs.SaveStringArray(name, value, m);
     return(DataPrefs.LoadStringArray(name));
 }
示例#19
0
 public static long Long(string name, long value, Mode m = 0)
 {
     DataPrefs.SaveLong(name, value, m);
     return(DataPrefs.LoadLong(name));
 }
示例#20
0
 public static string String(string name, string value, Mode m = 0)
 {
     DataPrefs.SaveString(name, value, m);
     return(DataPrefs.LoadString(name));
 }