파일 암호화 |
서버제 저장된 파일을 암호화하고 복호화할 수 있습니다.
서버에 저장되어 있는 기존 파일 또는 서버로 업로드하는 파일을 암호화해서 저장할 수 있습니다. EncryptFile 메서드를 호출하면 지정된 파일을 암호화해서 새로운 암호화된 파일이 생성됩니다.
아래 예제는 업로드된 파일을 암호화해서 저장하는 것을 보여줍니다. 업로드한 파일을 저장한 뒤 EncryptFile 메서드를 호출해 암호화합니다.
'업로드를 처리할 오브젝트를 생성합니다. Set Upload = Server.CreateObject("TABSUpload4.Upload") '업로드를 시작합니다. Upload.Start "C:\TEMP" Upload.Save "C:\TEMP", True '암호화를 처리할 오브젝트를 생성합니다. Set Encryptor = Server.CreateObject("TABSUpload4.Encryptor") '마스터 암호와 솔트 값으로 초기화합니다. Encryptor.InitializeFromIni "C:\MyPassword.ini" '업로드된 파일을 암호화해서 저장합니다. '저장시 확장자는 임의로 .enc를 붙입니다. Set UpFile = Upload.Form("uploadFile") encFile = UpFile.SaveName & ".enc" Encryptor.EncryptFile UpFile.SaveName, encFile
DecryptFile 메서드를 호출하면 암호화된 파일을 복호화해서 원본 파일로 저장할 수 있습니다.
아래 예제는 원본 파일로 복호화한 후 탭스 업로드의 Download 오브젝트를 사용해 웹 브라우저로 전송하는 방법을 보여줍니다.
'암호화를 처리할 오브젝트를 생성합니다. Set Encryptor = Server.CreateObject("TABSUpload4.Encryptor") '마스터 암호와 솔트 값으로 초기화합니다. Encryptor.InitializeFromIni "C:\MyPassword.ini" '암호화된 파일을 복호화 합니다. '복호화한 파일명은 .dec를 붙인다. saveFile = Request("fname") cipherFile = "C:\TEMP\" & saveFile & ".enc" downloadFile = cipherFile & ".dec" Encryptor.DecryptFile cipherFile, downloadFile Dim Download Set Download = Server.CreateObject("TABSUpload4.Download") '웹 브라우저로 데이터를 전송합니다. Download.FilePath = downloadFile Download.FileName = saveFile Download.TransferFile True, True