SymmetricGenerateKey

Description

Generates a secret key for asymmetric algorithm.

Applies to

CrypterObject objects

Syntax

crypter.SymmetricGenerateKey ( SymmetricAlgorithm algorithm, Integer len, ref Blob key )

Argument

Description

crypter

The name of the CrypterObject object.

algorithm

A value of the SymmetricAlgorithm enumerated type that specifies the type of symmetric algorithm.

Values are:

  • AES! – The Advanced Encryption Standard

  • DES! – The Data Encryption Standard

  • TDES! – The Triple-DES

  • DESX! – The DES-XEX3

  • Blowfish! – The Blowfish

len

An integer value specifying the key length.

Values are:

  • The value can be 16, 24, or 32 with AES

  • The value must be 8 with DES

  • The value can be 16 or 24 with TDES

  • The value must be 24 with DESX

  • The value can range from 4 to 56 with Blowfish

key

A blob specifying the secret key.

The length of the secret key can be 128 bits, 192 bits, 256 bits with AES.

The length of the secret key must be 64 bits with DES.

The length of the secret key can be 128 bits, 192 bits with TDES.

The length of the secret key must be 192 bits with DESX.

The length of the secret key can range from 32 bits to 448 bits with Blowfish.


Return value

Integer. Returns 1 if it succeeds and -1 if it failed. If any argument's value is null, the method returns null. If an error occurs, throw the exception.

Examples

CoderObject lco_Code
CrypterObject lco_Crypt
Blob lbb_Key, lb_Return, lb_Decrypt, lb_Data
Integer li_Return
String ls_Return

lco_Code = Create CoderObject
lco_Crypt = Create CrypterObject

li_Return = lco_Crypt.SymmetricGenerateKey(AES!,16,lbb_Key)
If li_Return = 1 Then
 lb_Data = Blob("Appeon", EncodingUTF8!)
 lb_Return = lco_Crypt.SymmetricEncrypt( AES!, lb_Data, lbb_Key)
 lb_Decrypt = lco_Crypt.SymmetricDecrypt( AES!, lb_Return, lbb_Key)
 ls_Return = String(lb_Decrypt, EncodingUTF8!)
End If

DesTroy ( lco_Crypt )
DesTroy ( lco_Code )

See also

SymmetricDecrypt

SymmetricEncrypt

AsymmetricEncrypt

AsymmetricDecrypt

AsymmetricSign

AsymmetricVerifySign

AsymmetricGenerateKey

MD5

SHA

HMAC