How to encrypt in VBScript using AES?

One way is to declare encryption classes within vbscript, without needing external added COM objects or wrapper. The following example takes a string, encrypts and decrypts using Rijndael managed class: ‘—————————————————– 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)) … Read more

Why do I need to use the Rfc2898DeriveBytes class (in .NET) instead of directly using the password as a key or IV?

You really, really do not want to use a user password directly as a crypto key, especially with AES. Rfc2898DeriveBytes is an implementation of PBKDF2. What it does is repeatedly hash the user password along with the salt. This has multiple benefits: Firstly, you can use arbitrarily sized passwords – AES only supports specific key … Read more