473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Signing and hashing in .net

Hi again,
I tried to write the following functions:

Public Function GetSignedHash(ByVal str As String) As Byte()
Dim ha As HashAlgorithm = SHA1.Create()
ha.ComputeHash(Encoding.ASCII.GetBytes(str))
GetSignedHash = rsa.SignHash(ha.Hash, CryptoConfig.MapNameToOID("SHA1"))
End Function

Public Function VerifySignedHash(ByVal bytes() As Byte) As Boolean
Dim ha As HashAlgorithm = SHA1.Create()
Dim rsapartner As New RSACryptoServiceProvider
rsapartner.FromXmlString(partnerpk)
ha.ComputeHash(bytes)
VerifySignedHash = rsapartner.VerifyHash(ha.Hash, CryptoConfig.MapNameToOID("SHA1"), bytes)
End Function

The first function hashes and signes some data, using the private key (in rsa), the other function uses the public key, that is stored in an XML string, to verify the hash. Now, here's the test code:

Dim serverhash() As Byte
serverhash = server.GetSignedHash("This is a test")
MsgBox(client.VerifySignedHash(serverhash))

This MsgBox should always print "true", but it doesn't..., so VerifyHash is always false. Can anyone tell me why?

Thanks a lot
Gordon

Jul 21 '05 #1
0 923

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin | last post by:
I have a couple of questions around code signing with MS technology: 1. Is there a way to transfer the generated strong name signing private key directly to a smartcard (or generate it on the...
0
by: Pollux | last post by:
Hi, I'm having a problem canonicalizing an xml document and getting a hash that matches that of an existing document so I was wondering if somebody knew what I was doing wrong. I generate an...
2
by: Derrick | last post by:
Hi All, I wrote an app that reads text and/or xml data, will call it our "content". We want to secure that content so that our app will know if someone has modified it, or has produced their own...
11
by: Wm. Scott Miller | last post by:
Hello all! We are building applications here and have hashing algorithms to secure secrets (e.g passwords) by producing one way hashes. Now, I've read alot and I've followed most of the advice...
0
by: Daniel | last post by:
Hi, I need help signing SOAP/XML. Have been stuck with this for a couple of days now. I get the following error message from the server: "The security token could not be authenticated or...
0
by: Raffi Basmajian | last post by:
I am trying to understand the difference between signing ClickOnce manifests and signing shared assemblies. My company is building .Net 2005 WinForm applications for internal company use only....
8
by: Maya | last post by:
Hello all, I'm using MD5 hashing in my application to give unique values to huge list of items my application receives, originally every item's name was difficult to use as an id for this item...
1
by: Tinku | last post by:
Hi friends I know Static Hashing and i know about Dynamic Hashing, still i have problem to make program with Dynamic Hashing I am new in "C" world, please help me, my problem is: i have to...
6
by: raylopez99 | last post by:
Anybody use Strong Name Signing? I think this is used by default for Resource files, which is one reason perhaps I can't get my resource files to work (somehow the public key is messed up, perhaps...
1
by: BillE | last post by:
<extreme frustration> I have googled and read about this, but can't seem to get a grip on it. Apparently I am being coerced into digitally signing applications. Is this true? What if I don't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.