Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
cryptencrypt (advapi32)
Encrypts the data in pbData using the encryption key pointed to by hKey which contains the encryption algorithm that is used.

C# Signature:

[DllImport(@"advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CryptEncrypt(IntPtr hKey, IntPtr hHash, int Final, uint dwFlags, byte[] pbData, ref uint pdwDataLen, uint dwBufLen);

VB Signature:

Declare Function CryptEncrypt Lib "advapi32.dll" (ByVal hkey As IntPtr, _
ByVal hHash As IntPtr, <MarshalAs(UnmanagedType.Bool)> ByVal final As Boolean, ByVal flags As Integer, _
ByVal data As Byte(), ByRef dataLen As Integer, ByVal bufferlen As Integer) _
As <MarshalAs(UnmanagedType.Bool)> Boolean

User-Defined Types:


Alternative Managed API:

Do you know one? Please contribute it!


The key's handle may be obtained by calling either of the CryptGenKey or CryptImportKey methods.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version