From: balzer on 4 May 2010 08:53 how to encrypt all files in folder(older that some data) with very strong algorithm use VBScript? VBScript FilePath = "\\server\folder" FileAge = 10 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(FilePath) Set colFile = objFolder.Files For Each objFile in colFile FileCreated = objFile.DateCreated If DateDiff("d", FileCreated, Now()) > FileAge Then ........ code to encrypt...... ......... Else End If And decrypting, when this required, to use separate vbscript-decryptor. Thanks.
From: Mayayana on 4 May 2010 09:09 There's no built-in functionality. Capicom.dll is the Windows library for encryption, but I don't think it's installed by default, and I don't think that script can use it. So your best option is probably to just look for a 3rd-party program for something like PGP, with command-line options. | how to encrypt all files in folder(older that some data) with very strong | algorithm use VBScript? | | | VBScript | | FilePath = "\\server\folder" | FileAge = 10 | | Set objFSO = CreateObject("Scripting.FileSystemObject") | Set objFolder = objFSO.GetFolder(FilePath) | Set colFile = objFolder.Files | For Each objFile in colFile | FileCreated = objFile.DateCreated | If DateDiff("d", FileCreated, Now()) > FileAge Then | | ....... code to encrypt...... | ........ | | Else | End If | | | And decrypting, when this required, to use separate vbscript-decryptor. | | Thanks. |
From: balzer on 4 May 2010 19:13 "Mayayana" <mayayana(a)invalid.nospam> wrote in message news:O4$BGr46KHA.5848(a)TK2MSFTNGP06.phx.gbl... > There's no built-in functionality. Capicom.dll is > the Windows library for encryption, but I don't > think it's installed by default, and I don't think > that script can use it. So your best option is > probably to just look for a 3rd-party program > for something like PGP, with command-line options. > > > | how to encrypt all files in folder(older that some data) with very strong > | algorithm use VBScript? > | > | > | VBScript > | > | FilePath = "\\server\folder" > | FileAge = 10 > | > | Set objFSO = CreateObject("Scripting.FileSystemObject") > | Set objFolder = objFSO.GetFolder(FilePath) > | Set colFile = objFolder.Files > | For Each objFile in colFile > | FileCreated = objFile.DateCreated > | If DateDiff("d", FileCreated, Now()) > FileAge Then > | > | ....... code to encrypt...... > | ........ > | > | Else > | End If > | > | > | And decrypting, when this required, to use separate vbscript-decryptor. > | > | Thanks. > | --------- well, I find AES string encryption in VBScript, example 1): Dim fso, outFile Set fso = CreateObject("Scripting.FileSystemObject") Set outFile = fso.CreateTextFile("output.txt", True) set crypt = CreateObject("Chilkat.Crypt2") success = crypt.UnlockComponent("Anything for 30-day trial") If (success <> 1) Then MsgBox "Crypt component unlock failed" WScript.Quit End If password = "secretPassPhrase" crypt.CryptAlgorithm = "aes" crypt.CipherMode = "cbc" crypt.KeyLength = 128 ' Generate a binary secret key from a password string ' of any length. For 128-bit encryption, GenEncodedSecretKey ' generates the MD5 hash of the password and returns it ' in the encoded form requested. The 2nd param can be ' "hex", "base64", "url", "quoted-printable", etc. hexKey = crypt.GenEncodedSecretKey(password,"hex") crypt.SetEncodedKey hexKey,"hex" crypt.EncodingMode = "base64" text = "The quick brown fox jumped over the lazy dog." ' Encrypt a string and return the binary encrypted data ' in a base-64 encoded string. encText = crypt.EncryptStringENC(text) outFile.WriteLine(encText) ' Decrypt and show the original string: decryptedText = crypt.DecryptStringENC(encText) outFile.WriteLine(decryptedText) outFile.Close and examples 2): http://www.example-code.com/vbscript/aes_dataStream.asp and 3): http://www.example-code.com/vbscript/crypt2_aes.asp which one will suit my needs better, and how to implement it into my code(encrypt all files in folder)? Decryption must be done with separate vbscript, where we should specify target folder and enter a decryption key. Thank you.
From: Mayayana on 4 May 2010 23:02 | | well, I find AES string encryption in VBScript, example 1): | | Dim fso, outFile | Set fso = CreateObject("Scripting.FileSystemObject") | Set outFile = fso.CreateTextFile("output.txt", True) | | set crypt = CreateObject("Chilkat.Crypt2") | | success = crypt.UnlockComponent("Anything for 30-day trial") | If (success <> 1) Then | MsgBox "Crypt component unlock failed" | WScript.Quit | End If | | password = "secretPassPhrase" | | crypt.CryptAlgorithm = "aes" | crypt.CipherMode = "cbc" | crypt.KeyLength = 128 | | ' Generate a binary secret key from a password string | ' of any length. For 128-bit encryption, GenEncodedSecretKey | ' generates the MD5 hash of the password and returns it | ' in the encoded form requested. The 2nd param can be | ' "hex", "base64", "url", "quoted-printable", etc. | hexKey = crypt.GenEncodedSecretKey(password,"hex") | crypt.SetEncodedKey hexKey,"hex" | | crypt.EncodingMode = "base64" | text = "The quick brown fox jumped over the lazy dog." | | ' Encrypt a string and return the binary encrypted data | ' in a base-64 encoded string. | encText = crypt.EncryptStringENC(text) | | outFile.WriteLine(encText) | | ' Decrypt and show the original string: | decryptedText = crypt.DecryptStringENC(encText) | | outFile.WriteLine(decryptedText) | outFile.Close | | | and examples | 2): http://www.example-code.com/vbscript/aes_dataStream.asp | and | 3): http://www.example-code.com/vbscript/crypt2_aes.asp | | | which one will suit my needs better, and how to implement it into my | code(encrypt all files in folder)? | Decryption must be done with separate vbscript, where we should specify | target folder and enter a decryption key. | Sorry, but I haven't used encryption, so I'm not familiar with the options. But I would think you could find something better than the Chilkat control. Their stuff is overpriced. The control you're looking at costs $149!
|
Pages: 1 Prev: Good editor for VBScript? Next: How to copy documents using links from excel to web folder |