Table of Contents

Class CPSecurityBaseClass

Namespace
Contensive.BaseClasses
Assembly
CPBase.dll
public abstract class CPSecurityBaseClass
Inheritance
CPSecurityBaseClass
Inherited Members

Methods

CheckHoneypot(string)

Check if the honeypot field was filled (indicates bot). Returns true if spam detected. If spam is detected, the request is automatically logged and the visitor is flagged. The honeypot field name defaults to "website_url" but can be customized.

public abstract bool CheckHoneypot(string honeypotFieldName = "website_url")

Parameters

honeypotFieldName string

Optional custom honeypot field name (default: "website_url")

Returns

bool

True if spam detected (honeypot was filled), false if legitimate user

CheckRateLimit(string, int)

Check if the visitor has submitted too recently. Returns true if rate limit exceeded. Uses visit-level storage tied to the specified action key. Automatically logs and flags the visitor if limit exceeded.

public abstract bool CheckRateLimit(string actionKey, int cooldownSeconds = 15)

Parameters

actionKey string

Unique key for this action (e.g., "contactFormSubmit", "commentPost")

cooldownSeconds int

Seconds required between submissions (default: 15)

Returns

bool

True if rate limit exceeded, false if OK to proceed

DecryptTwoWay(string)

Return an AES decrypted string. This is a symetric encryption. A value encrypted, can be decrypted back to the same string The result is not repeatable. If you encrypt the same source twice, the result may not be the same each time.

public abstract string DecryptTwoWay(string encryptedString)

Parameters

encryptedString string

Returns

string

EncryptOneWay(string)

return an encrypted string. This is a hash. One-way encryption cannot be reversed. This encrypted string is repeatable, so run the same encryption twice and the encryption will match

public abstract string EncryptOneWay(string unencryptedString)

Parameters

unencryptedString string

Returns

string

EncryptOneWay(string, string)

return an encrypted string. This is a hash. One-way encryption cannot be reversed. This encrypted string is repeatable, so run the same encryption twice and the encryption will match

public abstract string EncryptOneWay(string unencryptedString, string salt)

Parameters

unencryptedString string
salt string

Returns

string

EncryptTwoWay(string)

Return an AES encrypted string. This is a symetric encryption. A value encrypted, can be decrypted back to the same string The result is not repeatable. If you encrypt the same source twice, the result may not be the same each time.

public abstract string EncryptTwoWay(string unencryptedString)

Parameters

unencryptedString string

Returns

string

GetHoneypotHtml(string)

Generate HTML for a honeypot field. Insert this in your form template. The field is positioned off-screen and hidden from screen readers.

public abstract string GetHoneypotHtml(string fieldName = "website_url")

Parameters

fieldName string

Field name (default: "website_url")

Returns

string

HTML string ready to insert in form

GetRandomPassword()

Generate and return a random password string.

public abstract string GetRandomPassword()

Returns

string

RecordAction(string)

Record that the visitor successfully completed an action, starting the rate limit cooldown. Call this AFTER successful form processing.

public abstract void RecordAction(string actionKey)

Parameters

actionKey string

Same key used in CheckRateLimit()

SanitizeInput(string, string)

Sanitize user input for safe display. Removes or encodes dangerous patterns. Use this when you need to display user-submitted content.

public abstract string SanitizeInput(string userInput, string mode = "display")

Parameters

userInput string

Raw user input

mode string

Sanitization mode: "display" (HTML encode), "url" (URL encode), "sql" (strip SQL keywords - still use ORM!)

Returns

string

Sanitized string safe for the specified context

VerifyOneWay(string, string)

return true if an encrypted string matches an unencrypted string.

public abstract bool VerifyOneWay(string unencryptedString, string encryptedString)

Parameters

unencryptedString string
encryptedString string

Returns

bool