CryptoSys API Library Manual

PC1_File

Enciphers a file using the RC4-compatible 'PC1' algorithm. The key is passed as an array of bytes.

VB6/VBA Syntax

Public Declare Function PC1_File Lib "diCryptoSys.dll" (ByVal strFileOut As String, ByVal strFileIn As String, ByRef abKey As Byte, ByVal nKeyLen As Long) As Long

nRet = PC1_File(strFileOut, strFileIn, abKey(0), nKeyLen)

Parameters

strFileOut
[in] String with the full path name of the output file to be created.
strFileIn
[in] String with the full path name of the input file to be processed.
abKey
[in] Byte array containing the key.
nKeyLen
[in]Long containing the length of the key in bytes.

C/C++ Syntax

long _stdcall PC1_File(char *strFileOut, char *strFileIn, unsigned char *key, long keyBytes);

Returns (VB6/C)

Long: If successful, the return value is 0; otherwise it returns a non-zero error code.

.NET Equivalent

Pc1.File Method

Remarks

The key array abKey can be any length. The output file strFileOut will be overwritten without warning. The input and output filenames must not be the same.

Example

    Const MY_PATH As String = "C:\Test\"
    Dim abKey(5) As Byte
    Dim strFileOut As String
    Dim strFileIn As String
    Dim strFileChk As String
    Dim nRet As Long

    Debug.Print "Test_PC1_File..."
    ' Construct full path names to files
    strFileIn = MY_PATH & "hello.txt"
    strFileOut = MY_PATH & "hello.pc1.enc.dat"
    strFileChk = MY_PATH & "hello.pc1.chk.txt"

    ' Setup the 6-byte key "abcxyz"
    abKey(0) = Asc("a")
    abKey(1) = Asc("b")
    abKey(2) = Asc("c")
    abKey(3) = Asc("x")
    abKey(4) = Asc("y")
    abKey(5) = Asc("z")

    ' Encipher plaintext file
    nRet = PC1_File(strFileOut, strFileIn, abKey(0), 6&)
    Debug.Print "PC1_File returns " & nRet

    ' Now decipher just by repeating
    nRet = PC1_File(strFileChk, strFileOut, abKey(0), 6&)
    Debug.Print "PC1_File returns " & nRet

This should result in output as follows:

Test_PC1_File...
PC1_File returns 0
PC1_File returns 0

See Also

PC1_Bytes PC1_Hex

[Contents] [Index]

[HOME]   [NEXT: PC1_Hex...]

Copyright © 2001-11 D.I. Management Services Pty Ltd. All rights reserved.