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:
|
|
len |
An integer value specifying the key length. Values are:
|
|
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


