Return to HomePage


Code Examples Index

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

C#

Authentication

* Hash a Password Using a Random Salt (C)

Cookies

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

Cryptogrpahy

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

Data Access

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

I/O

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

Input and Data Validation

* Encoding Output within a (C)
* Validate User Input with Regular Expressions (C)
* Scoping Data Retrieval from the Request Object (C)

Registry

* Protect Data in the Registry Using Key Permissions (C)


ViewState

* Encrypting (C)

Web Services

* Perform XML schema validation of Web Service payload (C)


VB.NET


Authentication

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

Cookies

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

Cryptogrpahy

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

Data Access

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

I/O

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

Input and Data Validation

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

Registry

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

ViewState

* Encrypting (VB.NET)

Web Services

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



More Information

* Code Example Template
* Code example candidate list



Archive

* Security Code Examples 1



Return to HomePage
Microsoft Communities