public static void LoadProperties() { aesProperties = new AESProperties { InitializationVector = File.ReadAllBytes(AES_PROPERTIES_PATH_IV), Key = File.ReadAllBytes(AES_PROPERTIES_PATH_KEY) }; }
public static void GenerateKeyAndInitializationVectorIfNeeded() { if (!File.Exists(AES_PROPERTIES_PATH_IV) || !File.Exists(AES_PROPERTIES_PATH_KEY)) { using (System.Security.Cryptography.Aes aesAlg = System.Security.Cryptography.Aes.Create()) { AESProperties aesProperties = new AESProperties { InitializationVector = aesAlg.IV, Key = aesAlg.Key }; WriteToBinaryFile(AES_PROPERTIES_PATH_IV, aesProperties.InitializationVector); WriteToBinaryFile(AES_PROPERTIES_PATH_KEY, aesProperties.Key); } } }