Method: Key::WriteKeyFile
WriteKeyFile(FileName)
The
WriteKeyFile method writes the cipher key value stored within the
Key object, along
with a checksum, to a given file.
FileName
The
FileName argument is the full pathname of the file which will contain the cipher key.
If the specified file does not exist, it
will be created, whereas an existing file will be overwritten.
Example:
Private g_PathName As String
' . . .
Private Sub Command1_Click()
Dim intLength As Integer
Dim strKeyValue As String
Dim strFileName As String
Dim objKey As DGENCRYPTLib.Key
strKeyValue = Text1.Text
intLength = Len(strKeyValue)
' hexidecimal encoding produces 2 characters for every byte of data
If intLength <> 32 And intLength <> 48 And intLength <> 64 Then
MsgBox "the length of the key is invalid", vbExclamation
Exit Sub
End If
strFileName = Text2.Text
If strFileName = "" Then
MsgBox "please enter a name for the key file", vbExclamation
Exit Sub
End If
Set objKey = New DGENCRYPTLib.Key
objKey.HexKey = strKeyValue
objKey.WriteKeyFile g_PathName & strFileName
MsgBox "wrote '" & strFileName & "'"
Set objKey = Nothing
End Sub