I have this source code, - Imports System.IO
-
Imports System.Text
-
Imports System.Security.Cryptography
-
-
Module Module1
-
-
Sub Main()
-
-
-
End Sub
-
Public TheKey(7) As Byte
-
-
-
Private Vector() As Byte = {&H12, &H44, &H16, &HEE, &H88, &H15, &HDD, &H41}
-
-
-
-
Sub Encrypt(ByVal inName As String, ByVal outName As String)
-
Try
-
Dim storage(4096) As Byte 'create buffer
-
Dim totalBytesWritten As Long = 8 'Keeps track of bytes written.
-
-
Dim packageSize As Integer 'Specifies the number of bytes written at one time.
-
-
'Declare the file streams.
-
Dim fin As New FileStream(inName, FileMode.Open, FileAccess.Read)
-
Dim fout As New FileStream(outName, FileMode.OpenOrCreate, _
-
FileAccess.Write)
-
fout.SetLength(0)
-
-
Dim totalFileLength As Long = fin.Length 'Specifies the size of the source file.
-
-
'create the Crypto object
-
Dim des As New DESCryptoServiceProvider()
-
-
Dim crStream As New CryptoStream(fout, _
-
des.CreateEncryptor(TheKey, Vector), CryptoStreamMode.Write)
-
-
'flow the streams
-
While totalBytesWritten < totalFileLength
-
packageSize = fin.Read(storage, 0, 4096)
-
crStream.Write(storage, 0, packageSize)
-
totalBytesWritten = Convert.ToInt32(totalBytesWritten + packageSize / des.BlockSize * des.BlockSize)
-
End While
-
-
crStream.Close()
-
-
-
Catch e As Exception
-
MsgBox(e.Message)
-
End Try
-
-
End Sub
-
-
Sub Decrypt(ByVal inName As String, ByVal outName As String)
-
-
Try
-
-
Dim storage(4096) As Byte
-
Dim totalBytesWritten As Long = 8
-
Dim packageSize As Integer
-
Dim fin As New FileStream(inName, FileMode.Open, FileAccess.Read)
-
Dim fout As New FileStream(outName, FileMode.OpenOrCreate, _
-
FileAccess.Write)
-
fout.SetLength(0)
-
Dim totalFileLength As Long = fin.Length
-
-
-
Dim des As New DESCryptoServiceProvider()
-
Dim crStream As New CryptoStream(fout, _
-
des.CreateDecryptor(TheKey, Vector), CryptoStreamMode.Write)
-
-
Dim ex As Exception
-
-
While totalBytesWritten < totalFileLength
-
packageSize = fin.Read(storage, 0, 4096)
-
crStream.Write(storage, 0, packageSize)
-
totalBytesWritten = Convert.ToInt32(totalBytesWritten + packageSize / des.BlockSize * des.BlockSize)
-
Console.WriteLine("Processed {0} bytes, {1} bytes total", packageSize, _
-
totalBytesWritten)
-
End While
-
-
crStream.Close()
-
-
Catch e As Exception
-
MsgBox(e.Message & "Please ensure that you are using the correct password")
-
End Try
-
-
End Sub
-
-
Sub CreateKey(ByVal strKey As String)
-
-
' Byte array to hold key
-
Dim arrByte(7) As Byte
-
-
Dim AscEncod As New ASCIIEncoding()
-
Dim i As Integer = 0
-
AscEncod.GetBytes(strKey, i, strKey.Length, arrByte, i)
-
-
'Get the hash value of the password
-
Dim hashSha As New SHA1CryptoServiceProvider()
-
Dim arrHash() As Byte = hashSha.ComputeHash(arrByte)
-
-
'put the hash value into the key
-
For i = 0 To 7
-
TheKey(i) = arrHash(i)
-
Next i
-
-
End Sub
-
-
End Module
and i am getting this error
Name 'lt' is not declared.
and
Character is vaild
and ideas??
2 1440
Visual Studio would have stopped on the line where it has this problem, or the error pallet will tell you the file name and line number where the problem is.
On that line, you have a variable "It" that you are trying to use, only you have declared it before trying to use it.
It looks to be in your 'Flow the streams portion <
Try - While totalBytesWritten < totalFileLength
This is what happens when you just cut and paste code from a web page. The "<" (less than) symbol gets turned into an HTML entity "<"
There are two instances of this error that I can see....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mohammed Mazid |
last post by:
Can anyone please help me on how to move to the next and previous
question?
Here is a snippet of my code:
Private Sub cmdNext_Click()
End Sub
Private Sub cmdPrevious_Click()
showrecord
|
by: Stevey |
last post by:
I have the following XML file...
<?xml version="1.0"?>
<animals>
<animal>
<name>Tiger</name>
<questions>
<question index="0">true</question>
<question index="1">true</question>
</questions>
|
by: nospam |
last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types,
so, since it seems to me that Partial Types is still in the design or
development stages at Microsoft, I am going to ask...
|
by: Ekqvist Marko |
last post by:
Hi,
I have one Access database table including questions and answers. Now
I need to give answer id automatically to questionID column. But I
don't know how it is best (fastest) to do?
table...
|
by: glenn |
last post by:
I am use to programming in php and the way session and post vars are past
from fields on one page through to the post page automatically where I can
get to their values easily to write to a...
|
by: Rider |
last post by:
Hi, simple(?) question about asp.net configuration..
I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm
first start application the follow message shown.
=========
Server...
|
by: Jeff |
last post by:
In the function below, can size ever be 0 (zero)?
char *clc_strdup(const char * CLC_RESTRICT s)
{
size_t size;
char *p;
clc_assert_not_null(clc_strdup, s);
size = strlen(s) + 1;
|
by: spibou |
last post by:
In the statement "a *= expression" is expression assumed to be
parenthesized ? For example if I write "a *= b+c" is this the same
as "a = a * (b+c)" or "a = a * b+c" ?
|
by: Allan Ebdrup |
last post by:
Hi,
I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix
question is a question where you have several options that can all be rated
according to several possible ratings (from...
|
by: Zhang Weiwu |
last post by:
Hello!
I wrote this:
..required-question p:after {
content: "*";
}
Corresponding HTML:
<div class="required-question"><p>Question Text</p><input /></div>
<div...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |