Fortinet white logo
Fortinet white logo

Script Reference Guide

Global commands

Global commands

  • Crc32(str) — Returns the crc32 check value of the string, or 0 if it is an empty string.

  • Key_gen(str_pass, str_salt, iter_num, len_num) — Creates an AES key to encrypt/decrypt data, either generated by password or user defined.

  • Aes_enc(t) — Encrypts the data using the previously-created AES key.

  • Aes_dec(t) — Decrypts the data using the previously-created AES key.

  • EVP_Digest(alg, str) — EVP_Digest for one-shot digest calculation.

  • HMAC(alg, str, key) — HMAC message authentication code.

  • HMAC_verify(alg, data, key, verify) — Checks if the signature is the same as the current digest.

  • G2F(alg, key) — Returns a G2F random value.

  • Class_match(str, method, list) — Matches the string against an element.

  • Class_search(list, method, str) — Searches an element in the list against a string.

  • Cmp_addr() — Matches one IP address against a group of IP addresses. It can automatically detect IPv4 and IPv6 and can be used to compare IPv4 addresses with IPv6 addresses.

  • Url_enc(str) — Converts the URL information into valid ASCII format.

  • Url_dec(str) — Converts the encoding-URL into the original URL.

  • Url_parser(str) — Parses a URL, returns a table containing host, port, path, query, fragment, the username, password, etc., from the URL.

  • Url_compare(url1, url2) — Compares two URL strings, returns true if they are the same.

  • Rand() — Generates a random number. Returns an integer number. After FortiADC reboots, the random number will be different.

  • Srand(str) — Sets the random seed.

  • Rand_hex(int) — Generates a random number in HEX. Returns a string, length is the <int>.

  • Rand_alphanum(int) — Generates a random alphabet + number sequence. Returns a string, length is the <int>.

  • Rand_seq(int) — Generates a random number sequence. Returns a string, length is the <int>.

  • Time() — Returns the current time as a number in seconds. This is the time since the Epoch was measured.

  • Ctime() — Returns the current time as a string, for example, “Tue Jun 25 14:11:01 2019”.

  • Gmtime() — Returns the GMT time as a string, for example, “Thu 27 Jun 2019 18:27:42 GMT”.

  • Md5(str) — Returns the MD5 calculated for the specified string.

  • Md5_hex(str) — Returns the MD5 value in hex as a string.

  • Md5_str(str) — Calculates the MD5 of a string input and stores the results in an intermediate variable, in some cases you need a version to deal with it.

  • Md5_hex_str(str) — Calculates the MD5 of a string input of a string input and outputs the results in HEX format, in some cases you need a version to deal with it.

  • Sha1(str) — Returns the SHA-1 calculated for the specified string.

  • Sha1_hex(str) — Returns the SHA-1 calculated for the string in hex.

  • Sha1_str(str) — Calculates the SHA-1 of a string input and stores the results in an intermediate variable, in some cases you need a version to deal with it.

  • Sha1_hex_str(str) — Calculates the SHA-1 of a string input and output the results in HEX format, in some cases you need a version to deal with it.

  • Sha256(str) — Calculates the SHA-256 of a string input and stores the result in an intermediate variable.

  • Sha256_hex(str) — Calculates the SHA-256 of a string input and outputs the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha256_str(str) — Calculates the SHA-256 of a string input and stores the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha256_hex_str(str) — Calculates the SHA-256 of a string input and stores the result in an intermediate variable. In some case you need a version to deal with it.

  • Sha384(str) — Calculates the SHA-384 of a string input and stores the result in an intermediate variable.

  • Sha384_hex(str) — Calculates the SHA-384 of a string input and outputs the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha384_str(str) — Calculates the SHA-384 of a string input and stores the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha384_hex_str(str) — Calculates the SHA-384 of a string input and stores the result in an intermediate variable. In some case you need a version to deal with it.

  • Sha512(str) — Calculates the SHA-512 of a string input and stores the result in an intermediate variable.

  • Sha512_hex(str) — Calculates the SHA-512 of a string input and outputs the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha512_str(str) — Calculates the SHA-512 of a string input and stores the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha512_hex_str(str) — Calculates the SHA-512 of a string input and stores the result in an intermediate variable. In some case you need a version to deal with it.

  • B32_enc(str) — Encodes a string input in Base32 and outputs the result in string format.

  • B32_enc_str(str) — Encodes a string input in Base32 and outputs the result in string format. In some cases you need a version to deal with it.

  • B32_dec(str) — Decodes a Base32 encoded string input and outputs the result in string format.

  • B32_dec_str(str) — Decodes a Base32 encoded string input and outputs the result in string format. In some cases you need a version to deal with it.

  • B64_enc(str) — Encodes a string input in Base64 and outputs the result in string format.

  • B64_dec(str) — Decodes a Base64 encoded string input and outputs the result in string format.

  • Get_pid() — Returns the PID value of the VS process.

  • Table_to_string(t) — Returns the table in a string.

  • Htonl(int) — Converts a 32 bit long integer from host byte order to network byte order.

  • Ntohs(int) — Converts a 16 bit short integer from network byte order to host byte order.

  • Htons(int) — Converts a 16 bit short integer from host byte order to network byte order.

  • Ntohl(int) — When receiving long integers in HTTP response from the network, this command converts a 32 bit long integer from network byte order to host byte order.

  • To_HEX(str) — Returns the HEX calculate of the string.

  • Debug(str) — Prints the debug information when the virtual server is using HTTP scripting.

  • Log(str) — Prints the scripting running information in log format. When using this command, you should enable scripting log.

  • File_open(path, str) — Opens a file, returns a file object.

  • File_get(file, size) — Returns the file content.

  • File_close(file) — Closes a file.

Global commands

Global commands

  • Crc32(str) — Returns the crc32 check value of the string, or 0 if it is an empty string.

  • Key_gen(str_pass, str_salt, iter_num, len_num) — Creates an AES key to encrypt/decrypt data, either generated by password or user defined.

  • Aes_enc(t) — Encrypts the data using the previously-created AES key.

  • Aes_dec(t) — Decrypts the data using the previously-created AES key.

  • EVP_Digest(alg, str) — EVP_Digest for one-shot digest calculation.

  • HMAC(alg, str, key) — HMAC message authentication code.

  • HMAC_verify(alg, data, key, verify) — Checks if the signature is the same as the current digest.

  • G2F(alg, key) — Returns a G2F random value.

  • Class_match(str, method, list) — Matches the string against an element.

  • Class_search(list, method, str) — Searches an element in the list against a string.

  • Cmp_addr() — Matches one IP address against a group of IP addresses. It can automatically detect IPv4 and IPv6 and can be used to compare IPv4 addresses with IPv6 addresses.

  • Url_enc(str) — Converts the URL information into valid ASCII format.

  • Url_dec(str) — Converts the encoding-URL into the original URL.

  • Url_parser(str) — Parses a URL, returns a table containing host, port, path, query, fragment, the username, password, etc., from the URL.

  • Url_compare(url1, url2) — Compares two URL strings, returns true if they are the same.

  • Rand() — Generates a random number. Returns an integer number. After FortiADC reboots, the random number will be different.

  • Srand(str) — Sets the random seed.

  • Rand_hex(int) — Generates a random number in HEX. Returns a string, length is the <int>.

  • Rand_alphanum(int) — Generates a random alphabet + number sequence. Returns a string, length is the <int>.

  • Rand_seq(int) — Generates a random number sequence. Returns a string, length is the <int>.

  • Time() — Returns the current time as a number in seconds. This is the time since the Epoch was measured.

  • Ctime() — Returns the current time as a string, for example, “Tue Jun 25 14:11:01 2019”.

  • Gmtime() — Returns the GMT time as a string, for example, “Thu 27 Jun 2019 18:27:42 GMT”.

  • Md5(str) — Returns the MD5 calculated for the specified string.

  • Md5_hex(str) — Returns the MD5 value in hex as a string.

  • Md5_str(str) — Calculates the MD5 of a string input and stores the results in an intermediate variable, in some cases you need a version to deal with it.

  • Md5_hex_str(str) — Calculates the MD5 of a string input of a string input and outputs the results in HEX format, in some cases you need a version to deal with it.

  • Sha1(str) — Returns the SHA-1 calculated for the specified string.

  • Sha1_hex(str) — Returns the SHA-1 calculated for the string in hex.

  • Sha1_str(str) — Calculates the SHA-1 of a string input and stores the results in an intermediate variable, in some cases you need a version to deal with it.

  • Sha1_hex_str(str) — Calculates the SHA-1 of a string input and output the results in HEX format, in some cases you need a version to deal with it.

  • Sha256(str) — Calculates the SHA-256 of a string input and stores the result in an intermediate variable.

  • Sha256_hex(str) — Calculates the SHA-256 of a string input and outputs the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha256_str(str) — Calculates the SHA-256 of a string input and stores the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha256_hex_str(str) — Calculates the SHA-256 of a string input and stores the result in an intermediate variable. In some case you need a version to deal with it.

  • Sha384(str) — Calculates the SHA-384 of a string input and stores the result in an intermediate variable.

  • Sha384_hex(str) — Calculates the SHA-384 of a string input and outputs the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha384_str(str) — Calculates the SHA-384 of a string input and stores the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha384_hex_str(str) — Calculates the SHA-384 of a string input and stores the result in an intermediate variable. In some case you need a version to deal with it.

  • Sha512(str) — Calculates the SHA-512 of a string input and stores the result in an intermediate variable.

  • Sha512_hex(str) — Calculates the SHA-512 of a string input and outputs the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha512_str(str) — Calculates the SHA-512 of a string input and stores the result in an intermediate variable. In some cases you need a version to deal with it.

  • Sha512_hex_str(str) — Calculates the SHA-512 of a string input and stores the result in an intermediate variable. In some case you need a version to deal with it.

  • B32_enc(str) — Encodes a string input in Base32 and outputs the result in string format.

  • B32_enc_str(str) — Encodes a string input in Base32 and outputs the result in string format. In some cases you need a version to deal with it.

  • B32_dec(str) — Decodes a Base32 encoded string input and outputs the result in string format.

  • B32_dec_str(str) — Decodes a Base32 encoded string input and outputs the result in string format. In some cases you need a version to deal with it.

  • B64_enc(str) — Encodes a string input in Base64 and outputs the result in string format.

  • B64_dec(str) — Decodes a Base64 encoded string input and outputs the result in string format.

  • Get_pid() — Returns the PID value of the VS process.

  • Table_to_string(t) — Returns the table in a string.

  • Htonl(int) — Converts a 32 bit long integer from host byte order to network byte order.

  • Ntohs(int) — Converts a 16 bit short integer from network byte order to host byte order.

  • Htons(int) — Converts a 16 bit short integer from host byte order to network byte order.

  • Ntohl(int) — When receiving long integers in HTTP response from the network, this command converts a 32 bit long integer from network byte order to host byte order.

  • To_HEX(str) — Returns the HEX calculate of the string.

  • Debug(str) — Prints the debug information when the virtual server is using HTTP scripting.

  • Log(str) — Prints the scripting running information in log format. When using this command, you should enable scripting log.

  • File_open(path, str) — Opens a file, returns a file object.

  • File_get(file, size) — Returns the file content.

  • File_close(file) — Closes a file.