68 public override string[]
DefaultArgumentNames =>
new string[] {
"Content",
"Key",
"IV",
"CipherMode",
"PaddingMode" };
78 if (!(
Arguments[0].AssociatedObjectValue is
byte[] Data))
81 if (!(
Arguments[1].AssociatedObjectValue is
byte[] Key))
82 throw new ScriptRuntimeException(
"Key to use for encryption must be binary (i.e. an array of bytes).",
this);
84 if (!(
Arguments[2].AssociatedObjectValue is
byte[] IV))
85 throw new ScriptRuntimeException(
"Initiation Vector to use for encryption must be binary (i.e. an array of bytes).",
this);
88 CipherMode CipherMode = c <= 3 ? CipherMode.CBC : this.ToEnum<CipherMode>(
Arguments[3]);
89 PaddingMode PaddingMode = c <= 4 ? PaddingMode.PKCS7 : this.ToEnum<PaddingMode>(
Arguments[4]);
103 public static byte[]
Encrypt(
byte[] Data,
byte[] Key,
byte[] IV, CipherMode CipherMode = CipherMode.CBC, PaddingMode PaddingMode = PaddingMode.PKCS7)
106 throw new ArgumentNullException(nameof(Data));
109 throw new ArgumentNullException(nameof(Key));
112 throw new ArgumentNullException(nameof(IV));
114 using (Aes Aes = Aes.Create())
118 Aes.Mode = CipherMode;
119 Aes.Padding = PaddingMode;
121 using (ICryptoTransform Transform = Aes.CreateEncryptor(Key, IV))
123 return Transform.TransformFinalBlock(Data, 0, Data.Length);
Aes256Encrypt(ScriptNode Content, ScriptNode Key, ScriptNode IV, ScriptNode CipherMode, ScriptNode PaddingMode, int Start, int Length, Expression Expression)
AES Encryption
override string[] DefaultArgumentNames
Default Argument names
override string FunctionName
Name of the function
static byte[] Encrypt(byte[] Data, byte[] Key, byte[] IV, CipherMode CipherMode=CipherMode.CBC, PaddingMode PaddingMode=PaddingMode.PKCS7)
Performs AES encryption of data.
Aes256Encrypt(ScriptNode Content, ScriptNode Key, ScriptNode IV, int Start, int Length, Expression Expression)
AES Encryption
Aes256Encrypt(ScriptNode Content, ScriptNode Key, ScriptNode IV, ScriptNode CipherMode, int Start, int Length, Expression Expression)
AES Encryption
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Script runtime exception.
Class managing a script expression.
Base class for multivariate funcions.
static readonly ArgumentType[] argumentTypes3Normal
Three normal parameters.
static readonly ArgumentType[] argumentTypes4Normal
Four normal parameters.
ScriptNode[] Arguments
Function arguments.
static readonly ArgumentType[] argumentTypes5Normal
Five normal parameters.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
Basic interface for all types of elements.