473,320 Members | 2,012 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,320 software developers and data experts.

How to 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.

Expand|Select|Wrap|Line Numbers
  1. Public Function CalculateHMAC(ByVal data As String, ByVal key As String) As
  2. String
  3. Dim bData As Byte() = Encoding.UTF8.GetBytes(data)
  4. Dim bKey As Byte() = Encoding.UTF8.GetBytes(key)
  5. Dim hmac As HMACSHA1 = New HMACSHA1(bKey)
  6.  
  7. Using cryptoStream As CryptoStream = New CryptoStream(Stream.Null, hmac,
  8. CryptoStreamMode.Write)
  9. cryptoStream.Write(bData, 0, bData.Length)
  10. End Using
  11.  
  12. Return HexEncoding.ToString(hmac.Hash)
  13. End Function

Thanks!!
Jan 26 '11 #1
1 2086
Well, i figured it out...
if the key is for example: 0011FF
then it should go like
Expand|Select|Wrap|Line Numbers
  1. dim key as byte() = {&H00, &H11, &HFF}
Cheers
Jan 27 '11 #2

Sign in to post your reply or Sign up for a free account.

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...
2
by: Christian H | last post by:
Hello, I was thinking of using XML based digital signatures as a licensing scheme in my application: http://www.codeproject.com/dotnet/xmldsiglic.asp As the authtor points out, the public key...
4
by: PJones | last post by:
I am looking for the best way to one way encrypt a password for storage in a database using (asp.net / vb.net) basically I need some functions or examples that I can freely use in a commercial...
1
by: RedEye | 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...
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.