Beispiel #1
0
        static (byte[] key, byte[] iv) GetMachineSecretKey()
        {
            var guid = GetMachineSecretKeyGuid();
            var r    = AESUtils.GetParameters(guid.ToByteArray());

            return(r);
        }
Beispiel #2
0
        public void LocalEncrypt()
        {
            var value = DateTime.Now.ToString() + " 🔮🎮";

            var key_str = Environment.MachineName;

            (var key, var iv) = AESUtils.GetParameters(key_str);

            var aes_ofb = AESUtils.Create(mode: CipherMode.CFB);

            aes_ofb.Key = key;
            aes_ofb.IV  = iv;

            var data = AESUtils.EncryptToByteArray(aes_ofb, value);

            var value1 = AESUtils.DecryptToString(aes_ofb, data);

            Assert.IsTrue(value == value1);

            var aes_ofb_1 = AESUtils.Create(mode: CipherMode.CFB);

            aes_ofb_1.Key = key;
            aes_ofb_1.IV  = iv;

            var value2 = AESUtils.DecryptToString(aes_ofb, data);
            var value3 = AESUtils.DecryptToString(aes_ofb_1, data);

            Assert.IsTrue(value2 == value3);

            Assert.IsTrue(value1 == value3);
        }
Beispiel #3
0
 public GeneralLocalDataProtectionProvider(ILocalDataProtectionProvider.IProtectedData protectedData, ILocalDataProtectionProvider.IDataProtectionProvider dataProtectionProvider) : base(protectedData, dataProtectionProvider)
 {
     MachineSecretKey = AESUtils.GetParameters(Environment.MachineName);
 }