.NET Documentation     

DynCrypto .NET Component information

Class Name DynCrypto
Component File name NETDYNCRYPTO.DLL

How to use DynCrypto in a .NET application
 

.NET Framework version 1.1 required

  • For Visual Studio .NET projects, add NETDYNCRYPTO.DLL to your project references,
    for  ASP.NET application, copy NETDYNCRYPTO.DLL in your application "bin" directory.
     
  • Provide your DynCrypto license information:

    - copy the license file (DYNCRYPTO.INI) in your application "bin" directory
    - or, use method "LoadLicense" in your code
     
  • In your code create an instance of DynCrypto Class and call its functions:
     
    '--- Create an Instance of DynCrypto class  ---
    Dim DynCrypto As New dyncrypto
    '--- Load the license information if not ---
    '--- specified in a DYNCRYPTO.INI file ---
    DynCrypto.LoadLicense("LicenseOwner", "LicenseKey")
    
    '--- Encrypt ---
    dim CipherData as String 
    CipherData = DynCrypto.SymEncrypt("test", "MyTestString")

.NET DynCrypto Methods

Symmetric Key Cryptographic functions

Asymmetric Key Cryptographic functions

Hash functions (One Way functions)

DynCrypto Properties


SymEncrypt(Password as String, Data as String) as String

Encrypt a string using a Symmetric Key algorithm.

Syntax:

CipherText = DynCrypto.SymEncrypt(password,data)

Parameters Description
[in] password Encryption Password
[in] data String to encrypt
Return Value Encrypted string

ASP Example:

Set DynCrypto = server.CreateObject("DynCrypto.Crypto")
Password = "My Password"
Data = "Please encrypt this string"
CipherText = DynCrypto.SymEncrypt(password,Data)

VB.NET Example:

Dim DynCrypto As New netdyncrypto.dyncrypto
Dim CipherData As String

CipherData = DynCrypto.SymEncrypt("MyPassword", "A Test String")

Remark:

After encryption, the string is encoded with Base64. Therefore, it can safely be sent on the Internet. This method uses the algorithm CAST-128.


SymEncryptFile(Password as String, ClearFileName as String, CipherDir as String, ByRef OutputFileName as String , SetFileHash) as Int32

Encrypt a File using a Symmetric Key algorithm.

Syntax:

Result = DynCrypto.SymEncryptFile(Password,ClearFile,CipherDir,OutputFileName,true)

Parameters Description
[in] Password Encryption Password
[in] ClearFileName Full file name pointing the file to encrypt.
[in] CipherDir Must specify a directory or a file name (with its full path.) If a directory is specified, a default name will be chosen for the encrypted file. If a file name is specified, it will be used to create the encrypted file.
[out] CipherFileName Full path file name pointing the encrypted file.
[in] SetFileHash
 
Should be set to True or False. When True, a hash value of the clear file is stored in the header of the encrypted file. Therefore, while decrypting the encrypted file, the function will be able to check if the decryption process succeeded. In other words, that the password was correct and that the encrypted file was not corrupted. When enabled, the processing time for encryption and decryption is increased. Default value is True.
Return Value Zero on success, Nonzero on failure. The value returned is an Win32 error code.

Example: 

Refer to sample: Symmetric Key File Encryption/Decryption

Remark:

This method uses the algorithm CAST-128.


SymDecrypt(Password as String, Data as String) as String

Decrypt a string encrypted with method "SymEncrypt." Use a Symmetric Key algorithm.

Syntax:

CipherText = DynCrypto.SymDecrypt(password,data)

Parameters Description
[in]  Password Encryption Password
[in] Data Encrypted string to decrypt.
Return Value Decrypted Data. Stored in String.

VB.NET Example:

Dim DynCrypto As New netdyncrypto.dyncrypto
Dim CipherData As String
Dim ClearData As String

'--- Encrypt a String
CipherData = DynCrypto.SymEncrypt("MyPassword", "MyTestString")
 

'--- Decrypt a crypted string
ClearData = DynCrypto.SymDecrypt("MyPassword", CipherData)
 


SymDecryptFile(Password as String, CipherFile as String, ClearDir as String, ByRef OutputFileName as String , ByRef HashCheckResult as Boolean)

Decrypt an encrypted file with method "SymEncryptFile." Uses a Symmetric Key algorithm.

Syntax:

Result  = DynCrypto.SymDecryptFile(Password,CipherFile,ClearDir,OutputFileName,HashCheckResult)

Parameters Description
[in]  Password Decryption password 
[in] CipherFile Full file name pointing the file to decrypt.
[in] ClearDir Define a directory or a file name (with its full path.) If a directory only is specified, the original name of the clear file will be given to the uncrypted file. If a file name is specified, it will be used to create the decrypted file.
[out] OutputFileName Full path file name pointing the decrypted file.
[out] HashCheckResult This variable is set to True or False by function. True means that the decryption process succeeded. False means that it failed. Failure is usually due to an invalid password. If option HashCheckResult was not enabled while encrypting the file, False is always returned. However, the decryption process, still may or may not succeed.
Return Value Zero on success, Nonzero on failure. The value returned is a Win32 error code.

Example:

Refer to sample: Symmetric Key File Encryption/Decryption


AsymEncrypt(PublicKey as String, Data as String) as String

Encrypt a string using an Asymmetric Key algorithm.

Syntax:

CipherText = DynCrypto.AsymEncrypt(PublicKey,data)

Parameters Description
[in] PublicKey Public encryption Key. String value generated with function "AsymPublicKey."
[in] Data String to encrypt
Return Value Encrypted Data. The string Base64 encoded.

Example:

Refer to sample: Asymmetric Key String Encryption/Decryption

Remark:

After encryption, the string is encoded with Base64. Therefore, it can safely be sent on the Internet. This method uses two algorithms: Elliptic Curve and CAST-128.


AsymEncryptFile(PublicKey as String, ClearFileName as String, CipherFileName as String, ByRef OutputFileName as String, ByRef SetFileHash as Boolean) as Int32

Encrypt a File using an Asymmetric Key algorithm.

Syntax:

Result = DynCrypto.AsymEncryptFile(PublicKey,ClearFile,CipherFileName,OutputFileName,HashCheckResult)

Parameters Description
[in] PublicKey Public encryption Key. String value generated with function "AsymPublicKey."
[in] ClearFileName Full file name pointing the file to encrypt.
[in] CipherFileName Define a directory or a file name (with its full path.) If a directory only is specified, a default name will be affected to the encrypted file. If a file name is specified, it will be used to create the encrypted file.
[out] OutputFileName Full path file name pointing the encrypted file.
[in] SetFileHash Should be set to True or False. When enabled, a hash value of the clear file is stored in the header of the encrypted file. Therefore, while decrypting the encrypted file, the function will be able to check if the decryption process succeeded. In other words, that the password was correct and that the encrypted file was not corrupted. When enabled, the processing time for encryption and decryption is increased. Default value is True.
Return Value Zero on success, Nonzero on failure. The value returned is a Win32 error code.

Example: 

Refer to sample: Asymmetric Key File Encryption/Decryption

Remark:

This method uses two algorithms: Elliptic Curve and CAST-128.


AsymDecrypt(PrivateKey as String, Data as String)

Decrypt a string encrypted with method "AsymEncrypt." Use Asymmetric Algorithm.

Syntax:

CipherText = DynCrypto.AsymDecrypt(PrivateKey,data)

Parameters Description
[in] PrivateKey Private key to decrypt the encrypted data. String Value.
[in] Data Encrypted string to decrypt. String Value.
Return Value Decrypted Data. Stored in String.

Example:

Refer to sample: Asymmetric Key String Encryption/Decryption


AsymDecryptFile(PrivateKey as String, CipherFileName as String, ClearFileName as String, ByRef OutputFileName, ByRef HashCheckResult as Boolean) as Int32

Decrypt an encrypted file with method "AsymEncryptFile." Use an Asymmetric Key algorithm.

Syntax:

Result  = DynCrypto.AsymDecryptFile(PrivateKey,CipherFile,ClearFile,OutputFile,HashCheckResult)

Parameters Description
[in]  PrivateKey Private Decryption Key
[in] CipherFileName Full file name pointing the file to decrypt.
[in] ClearFileName Define a directory or a file name (with its full path.) If a directory only is specified, the original name of the clear file will be given to the uncrypted file. If a file name is specified, it will be used to create the decrypted file.
[out] OutputFileName Full file name given to the decrypted file.
[out] HashCheckResult This variable is True or False by function. True means that the decryption process succeeded. False means that it failed. Failure is usually due to an invalid password. If option HashCheck was not enabled while encrypting the file, False is always returned. However, the decryption process, still may or may not succeed.
Return Value Zero on success, Nonzero on failure. The value returned is a Win32 error code.

Example:

Refer to sample: Asymmetric Key File Encryption/Decryption


AsymPublicKey(PrivateKey as String) as String

Generate a public key from a private key.

Syntax:

PublicKey = DynCrypto.AsymPublicKey(PrivateKey)

Parameters Description
[in] PrivateKey Private Key. String value.
Return Value Public Key. Base64 String Value.

VB.NET Example:

Dim DynCrypto As New netdyncrypto.dyncrypto
Dim PublicKey As String

PublicKey = DynCrypto.AsymPublicKey("MyPrivateKey")


Hash(Data as String) as String

Generate a Hash value from a data string.

Syntax:

HashString = DynCrypto.Hash(Data)

Parameters Description
[in] Data Data. String value.
Return Value Hash Value Base64 coded, stored in a string

VB.NET Example:

Dim DynCrypto As New netdyncrypto.dyncrypto
Dim HashString As String

HashString = DynCrypto.Hash("Please Hash this string")


HashToArray(Data as String) as System.Array

Generate a Hash value from a data string.

Syntax:

HashArray = DynCrypto.HashToArray(Data)

Parameters Description
[in] Data Data. String value.
Return Value Hash value stored in a System.Array

VB.NET Example:

Dim DynCrypto As New netdyncrypto.dyncrypto
Dim HashArray As Array

HashArray = DynCrypto.HashToArray("Please Hash this string")

 


HashFile(FileName as String) as String

Generate a Hash value from a file.

Syntax:

HashValue = DynCrypto.HashFile(FileName)

Parameters Description
[in] FileName Full path file name. String value.
Return Value Hash Value Base 64 coded, stored in a string.

VB.NET Example:

Dim DynCrypto As New netdyncrypto.dyncrypto
Dim HashString As String

HashString = DynCrypto.HashFile("c:\temp\news.txt")


HashFileToArray(FileName as String) as String

Generate a Hash value from a file.

Syntax:

HashValue = DynCrypto.HashFile(FileName)

Parameters Description
[in] FileName Full path file name. String value.
Return Value Hash value stored in a System.Array.

VB.NET Example:

Dim DynCrypto As New netdyncrypto.dyncrypto
Dim HashArray As Array

HashArray = DynCrypto.HashFileToArray("c:\temp\news.txt")


BreakOnDecryptError

Define if DynCrypto will throw exceptions on decryptio failures. This usually occurs when the password is invalid.

Syntax:                            

DynCrypto.BreakOnDecryptError = true or false

Settings:

If "true," the component will throw exceptions on decryption failures.
If "false," the component will NOT throw exception on decryption failure.
Default value is "true."


LicenseInfo

Return information on the license currently registered.

Syntax:

CurrentLicenseInfo = DynCrypto.LicenseInfo


LoadLicense(Owner, Key)

Load the license information.

Syntax:

License = DynCrypto.LoadLicense(Owner,Key)

Parameters Description
[in] Owner Owner. Part of the license information.
[in] Key Key.  Part of the license information.
Return Value Non zero if license information is valid.

Remark:

If parameter "Owner" and "Key" are empty, the component will search the license information in file DYNCRYPTO.INI located in the same directory as NETDYNCRYPTO.DLL. If parameter "Owner" and "Key" are specified with invalid values, file DYNCRYPTO.INI is not searched and not needed.


Version(Integer Option)

Return information on the current version of DynCrypto component.

Syntax:

VersionInfo = DynCrypto.Version(0)

Parameters Description
[in] Option
(Optional)
Acceptable values are:
0: Default Value. Return the version information in a string value.
1: Return the version information in long integer value. Useful for version comparison.
2: Return the version information of the internal cryptographic library.
 

                                                          DynCrypto is an OpenFuture Software, Inc. Product