When trying to make a secure encryption system for some secret keys, I wanted to see if we can encrypt the file containing the key in VBScript using AES
Looking at other posts, I found that:
'-----------------------------------------------------
Dim obj,arr,i,r,str,enc,asc
dim bytes,bytesd,s,sc,sd
set obj=WScript.CreateObject("System.Security.Cryptography.RijndaelManaged")
Set asc = CreateObject("System.Text.UTF8Encoding")
s="This is a private message"
bytes=asc.GetBytes_4(s)
obj.GenerateKey()
obj.GenerateIV()
set enc=obj.CreateEncryptor()
set dec=obj.CreateDecryptor()
bytec=enc.TransformFinalBlock((bytes),0,lenb(bytes))
sc=asc.GetString((bytec))
msgbox sc
byted=dec.TransformFinalBlock((bytec),0,lenb(bytec))
sd=asc.GetString((byted))
msgbox sd
'-----------------------------------------------------
This is useful to encrypt a string, but, it will be possible to set a default key and IV to the AES encryption, because I want to encrypt a and decrypt file, so I need to have already a key and IV to decrypt.
Is there any way to encrypt a file in VBScript using AES?