Return to HomePage


Code Examples Index

This page is a catalog of security code examples. Each example is a discrete block of code that includes the intentions and insight behind the code. The examples were drawn from a code example candidate list Each code example uses the Code Example Template

Authentication

* Hash a Password Using a Random Salt (C | VB.NET )

Cookies

* Decrypt validate encrypted signed cookie (C | VB.NET
* Encrypting and Signing a cookie for use by an external web application (C |VB.NET
* Setting application and ASP.NET 2.0 cookies securely (C | VB.NET



Cryptography

* Creating and securely storing a symmetric encryption key and Initialization Vector (C | VB.NET
* Decrypt a file via a block cipher using 3DES (C | VB.NET
* Decrypt a file via a block cipher using AES (C | VB.NET
* Decrypt a string via a block cipher using 3DES (C | VB.NET
* Decrypt a string via a block cipher using AES (C | VB.NET
* Encrypt a file via a block cipher using 3DES (C | VB.NET
* Encrypt a file via a block cipher using AES (C | VB.NET
* Export the Public Key from an RSA Key Pair for Distribution (C | VB.NET
* Generate a Message Authentication Code (C | VB.NET
* Generate an RSA signature of a given message (C | VB.NET
* Generate RSA Keys and Store in the Registry Using DPAPI (C | VB.NET
* Generating Cryptographically Secure Random Numbers (C | VB.NET
* Import an RSA Public Key from a file and Encrypt a Message (C | VB.NET
* Retrieve an RSA Key Pair from the Registry and Decrypt a Message (C | VB.NET
* Validate an RSA signature of a given message (C | VB.NET

Data Access

* Protect Credentials Within a Connection String in Code (C | VB.NET
* Using Parameterized Queries for Secure Database Access (C | VB.NET
* Using Stored Procedures for Secure Database Access (C | VB.NET


I/O

* Creating a temporary file which avoids canonicalization and race conditions (C | VB.NET
* Securely Executing a New Process from a .NET Application (C | VB.NET

Input and Data Validation

* Encoding Output within a DataTable (C | VB.NET
* Scoping Data Retrieval from the Request Object (C | VB.NET
* Validate User Input with Regular Expressions (C | VB.NET



Registry

* Protect Data in the Registry Using Key Permissions (C | VB.NET


ViewState

* Encrypting ViewState (C | VB.NET

Web Services

* Perform XML schema validation of Web Service payload (C | VB.NET




More Information

* Code Example Template
* Code example candidate list



Archive

* Security Code Examples 1
* Security Code Examples 2



Return to HomePage