public static bool CreateDecryptedImages(string sessionId) { string[] filePaths = GetEncryptedImagePaths(sessionId); foreach (string path in filePaths) { try { byte[] fileBytes = File.ReadAllBytes(path); byte[] decrypted = CacheEncrypter.DecryptData(fileBytes, CommonConst.DES_KEY); CacheUtils.ByteToImage(decrypted).Save(string.Format("{0}\\{1}\\{2}", CommonConst.LOCAL_CACHE_PATH, sessionId, Path.GetFileName(path).Replace(CommonConst.ENCR_IMG_EXT, CommonConst.DECR_IMG_EXT))); } catch { } } return(true); }
public static bool DecryptData(string sessionId) { if (!File.Exists(GetDataEncryptedFilePath(sessionId))) { return(true); } try { byte[] encrypted = File.ReadAllBytes(GetDataEncryptedFilePath(sessionId)); byte[] decrypted = CacheEncrypter.DecryptData(encrypted, CommonConst.DES_KEY); File.WriteAllText(GetDataDecryptedFilePath(sessionId), CacheUtils.GetString(decrypted)); } catch { } return(true); }