Enciphers a file using the RC4-compatible 'PC1' algorithm.
VB6/VBA
Debug.Print "Testing PC1_File ..." Const MY_PATH As String = ".\" 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
Output
Testing PC1_File ... Test_PC1_File... PC1_File returns 0 PC1_File returns 0
VB.NET
[Contents]