CryptoSys API Library Manual

PC1_File

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

VBA/VB6 Syntax

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

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

C/C++ Syntax

long __stdcall PC1_File(char *szFileOut, char *szFileIn, unsigned char *lpKey, long nKeyBytes);

Parameters

szFileOut
[in] with the full path name of the output file to be created.
szFileIn
[in] with the full path name of the input file to be processed.
lpKey
[in] array containing the key.
nKeyBytes
[in] containing the length of the key in bytes.

Returns (VBA/C)

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

.NET Equivalent

Pc1.File Method

Remarks

The key array lpKey can be any length. The output file szFileOut 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]

[PREV: PC1_Bytes...]   [Contents]   [Index]   
   [NEXT: PC1_Hex...]

Copyright © 2001-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-07T07:42:00Z.