[VB6 equivalent: BLF_File]
Const MY_PATH As String = ".\" Dim abKey() As Byte Dim strFileOut As String Dim strFileIn As String Dim strFileChk As String Dim nRet As Integer ' Construct full path names to files strFileIn = MY_PATH & "hello.txt" strFileOut = MY_PATH & "hello.blf.enc.dat" strFileChk = MY_PATH & "hello.blf.chk.txt" ' Create the key as an array of bytes ' This creates an array of 8 bytes {&HFE, &HDC, ... &H10} abKey = Cnv.FromHex("fedcba9876543210") ' Encrypt plaintext file to cipher ' WARNING: output file is just clobbered nRet = Blowfish.FileEncrypt(strFileOut, strFileIn, abKey, Mode.ECB, Nothing) Console.WriteLine(nRet) ' Output file should be a 16-byte file hello.enc ' containing the following values in hexadecimal: ' 1A A1 51 B7 7A 5A 33 5C 4E 7E DC 84 A3 86 DC 96 ' Now decrypt it nRet = Blowfish.FileDecrypt(strFileChk, strFileOut, abKey, Mode.ECB, Nothing) Console.WriteLine(nRet)
See Also:
Blowfish.FileDecrypt Method (String, String, Byte[], Mode, Byte[])
Blowfish.FileEncrypt Method (String, String, Byte[], Mode, Byte[])