This function doesn't seem to be giving me the appearance I expect. This
should appear more like
"1ba442ab45c800 2a86d068d1c1748 e44" but it looks really cryptic and screwy,
like "*óìØLÜzrVÊ %' \Y7".
Here is my code segment written in VB.NET Enterprise Architect:
--------
Public Function MD5File(ByVal Filename As String) As String
'
' Read a file, produce an MD5 hashed key value in a String.
'
With New Security.Crypto graphy.MD5Crypt oServiceProvide r
Dim result() As Byte = .ComputeHash( New
IO.StreamReader (Filename).Base Stream )
Dim Encoding As Text.Encoding = System.Text.Enc oding.Default
Return Encoding.GetStr ing(result)
Encoding = Nothing
.Clear()
End With
End Function
---------
Perhaps you can suggest a modification to my code which yields a more
hex-like string. I'm new to VB.NET, but I love it so far.
Thanks,
~ Shaun
near Seattle, WA 2 4470
Hi there,
This is much easier done by loading the file into a byte array first,
Imports System.Security .Cryptography
Public Function createHash(ByVa l iByteArray() As Byte) As String
Dim pBytHash() As Byte
pBytHash = New MD5CryptoServic eProvider().Com puteHash(iByteA rray)
Return (BitConverter.T oString(pBytHas h, 0, pBytHash.GetUpp erBound(0)))
End Function
You can then use the above function to get an MD5 Hash of the data.
Nick.
"Shaun Merrill" <sm*******@comc ast.net> wrote in message
news:u3******** ******@TK2MSFTN GP09.phx.gbl... This function doesn't seem to be giving me the appearance I expect. This should appear more like "1ba442ab45c800 2a86d068d1c1748 e44" but it looks really cryptic and screwy, like "*óìØLÜzrVÊ %' \Y7".
Here is my code segment written in VB.NET Enterprise Architect: -------- Public Function MD5File(ByVal Filename As String) As String ' ' Read a file, produce an MD5 hashed key value in a String. ' With New Security.Crypto graphy.MD5Crypt oServiceProvide r Dim result() As Byte = .ComputeHash( New IO.StreamReader (Filename).Base Stream ) Dim Encoding As Text.Encoding = System.Text.Enc oding.Default Return Encoding.GetStr ing(result) Encoding = Nothing .Clear() End With End Function --------- Perhaps you can suggest a modification to my code which yields a more hex-like string. I'm new to VB.NET, but I love it so far. Thanks, ~ Shaun near Seattle, WA
Shaun,
The result you are getting is actually correct... it's just not formatted in
"nice-hex-format", you still have it as raw data.
Here's a quick code snippet that will take your raw data, and display it how
you want...
///
Dim strMD5 As String
For Each bytByte As Byte In result
strMD5 &= bytByte.ToStrin g("x2")
Next
///
Now, strMD5 contains the nicely formatted MD5 hash. (Assuming 'result' is
your byte array).
Also, you have an unreachable code segment in your code: Encoding = Nothing .Clear()
These two lines will *never* be called, because they are preceeded with a
'Return' statement, which exits the method.
Hope this helps!
-- Tom Spink
"Shaun Merrill" wrote:
This function doesn't seem to be giving me the appearance I expect. This should appear more like "1ba442ab45c800 2a86d068d1c1748 e44" but it looks really cryptic and screwy, like "Â*óìØLÃœzrV Ê%' \Y7".
Here is my code segment written in VB.NET Enterprise Architect: -------- Public Function MD5File(ByVal Filename As String) As String ' ' Read a file, produce an MD5 hashed key value in a String. ' With New Security.Crypto graphy.MD5Crypt oServiceProvide r Dim result() As Byte = .ComputeHash( New IO.StreamReader (Filename).Base Stream ) Dim Encoding As Text.Encoding = System.Text.Enc oding.Default Return Encoding.GetStr ing(result) Encoding = Nothing .Clear() End With End Function --------- Perhaps you can suggest a modification to my code which yields a more hex-like string. I'm new to VB.NET, but I love it so far. Thanks, ~ Shaun near Seattle, WA
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bill Burwell |
last post by:
I am converting a VB6 WebClass application to VB.Net. Used the VB upgrade
tool to do the conversion - and it left me a lot of little code things to
do. Did those code things and got my app to compile. Did a few other code
things to take advantage of .Net features not available in VB6.
When I start the application on my PC I get the error shown below. It seems
to me that the app initiation is failing before any app code is executed.
My...
|
by: Bshowers |
last post by:
I need to generate an MD5 hash in ASP, not ASP.NET, and have that hash be
the same as what is produced by the .NET MD5CryptoServiceProvider.
This is the vb.net code I am using...
Function GenerateMD5Hash(ByVal SourceText As String) As String
'Create an encoding object to ensure the encoding standard for the
source text
Dim Ue As New UnicodeEncoding
'Retrieve a byte array based on the source text
Dim ByteSourceText() As Byte =...
|
by: Bryan Olson |
last post by:
The current Python standard library provides two cryptographic
hash functions: MD5 and SHA-1 . The authors of MD5 originally
stated:
It is conjectured that it is computationally infeasible to
produce two messages having the same message digest.
That conjecture is false, as demonstrated by Wang, Feng, Lai and
Yu in 2004 . Just recently, Wang, Yu, and Lin showed a short-
cut solution for finding collisions in SHA-1 . Their result
|
by: flipdog |
last post by:
Hello all,
I didn't know there is a thread on hash function started in this newsgroup
so reposted my posting from another group.
Hope I can have some feedbacks. I am new to hash table.
I came across a very well presented tutorial web page wrt hash table. In
its content, it listed a number of hash functions which the web master(?)
quoted from other web sites. So no explainations for these hash functions
and I failed to understand a...
|
by: Phil Townsend |
last post by:
I have been asked to rewrite some apps that contain databases of
username and passwords to store the passwords as hashes. Getting the
data into a hash format is no problem. however, how do I go about
reading the hash value to validate a user? Is there a method of the
FormsAuthentication class for doing this?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
| |
by: John M |
last post by:
Hello,
Something quire is on my application.
If I don't touch the computer for about 30 minutes,
I get the message (something like) hash.exe is not accesible due security
....
Any idea.
Thanks :)
|
by: c676228 |
last post by:
Hi,
I have met this problem for many times, I don't how to fix it, the only
thing I can do is to restart the computer. Here is the case:
Sometimes when I change the behide class code, and then rebuild, then when I
open the .aspx page, the following error message comes up.
Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary
ASP.NET Files\subway\1202412f\df2ea907\hash.web" is denied.
Description: An unhandled...
|
by: johnnyG |
last post by:
Greetings,
I'm studying for the 70-330 Exam using the MS Press book by Tony Northrup
and there are 2 side-by-side examples of using the SHA1CryptoServiceProvider
to create a hash value from a string.
The vb example outputs "A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"
The cs example outputs "5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8"
for the string "password"
Question: do the 2 applications use different automatic "salts" or "seeds"
to...
|
by: andrewcw |
last post by:
I have a VB 5 module that duplicates the FCIV.exe from Microsoft. I need to
move an application forward to C#, but the samples for MD5 hash using the
framework I tried gave different hashes. What do I feed the framework and
how do I get the same values ??
The following code DOES NOT GIVE THE FCIV value:
public string getFileHash(string filePath)
{
string retVal = "";
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |