473,386 Members | 1,654 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,386 software developers and data experts.

How can I set the HMACSHA1 key to hex?

I have tested the output against a hash calculation application. Every thing
works fine but the only problem is that in order for the hash to match the
ap's hash the HMACSHA1.Key needs to be set to HEX. Is there a different
encoding type I should be using?

Any help would be appreciated.

Below is the code in it's current form.

Public Function CalculateHMAC(ByVal data As String, ByVal key As String) As
String
Dim bData As Byte() = Encoding.UTF8.GetBytes(data)
Dim bKey As Byte() = Encoding.UTF8.GetBytes(key)
Dim hmac As HMACSHA1 = New HMACSHA1(bKey)

Using cryptoStream As CryptoStream = New CryptoStream(Stream.Null, hmac,
CryptoStreamMode.Write)
cryptoStream.Write(bData, 0, bData.Length)
End Using

Return HexEncoding.ToString(hmac.Hash)
End Function
Thanks!!
May 17 '06 #1
1 2020
I got it to work...

It always seem to work out after you post it to the group.

Thanks!
"RedEye" <re*******@hotmail.com> wrote in message
news:Og*************@TK2MSFTNGP05.phx.gbl...
I have tested the output against a hash calculation application. Every
thing works fine but the only problem is that in order for the hash to
match the ap's hash the HMACSHA1.Key needs to be set to HEX. Is there a
different encoding type I should be using?

Any help would be appreciated.

Below is the code in it's current form.

Public Function CalculateHMAC(ByVal data As String, ByVal key As String)
As String
Dim bData As Byte() = Encoding.UTF8.GetBytes(data)
Dim bKey As Byte() = Encoding.UTF8.GetBytes(key)
Dim hmac As HMACSHA1 = New HMACSHA1(bKey)

Using cryptoStream As CryptoStream = New CryptoStream(Stream.Null, hmac,
CryptoStreamMode.Write)
cryptoStream.Write(bData, 0, bData.Length)
End Using

Return HexEncoding.ToString(hmac.Hash)
End Function
Thanks!!

May 17 '06 #2

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

Similar topics

4
by: Dave Bailey | last post by:
I have an application installed on a web server. When forst intalled it worked fine. The administrator rebooted the server and then when accessing the app the folowing error appears: CryptoAPI...
2
by: Leonardo D'Ippolito | last post by:
Hi! I have two .NET win apps that need to communicate on a TCP/IP network. 'App A' must ask 'app B' if it's allowed to do some task, and 'app B' must authorize or prohibit it. How can I do...
2
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...
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...
11
by: Matthew | last post by:
Ok let me try to explain this as good as I can. I am creating this application where it contains a userlogin class. The user logs in before entering the main apploication. I want to do audit trails...
1
by: mattgcon | last post by:
Here is my question. I am encrypting user login passwords using HMACSHA1 and I would like to know how to decrypt the passwords for displaying to managers and when emailing the password to the user if...
1
by: oimenoi | last post by:
I am keep having the "No overload for method 'GenerateSignature' takes 9 arguments" problem. Can you please tell me what is wrong with this class. This code is the sample from the Oauth.net . I...
1
by: maxi max | last post by:
I have tested the output against a hash calculation application. Every thing works fine but the only problem is that in order for the hash to match the ap's hash the HMACSHA1.Key needs to be set to...
1
by: Don Clemens | last post by:
Ok, so I downloaded a class online (OAuthBase.cs). Every time I plug it into my project, I am getting "The name 'HttpUtility' does not exist in the current context" error. I got this from the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.