HMAC512 script en Base64 encoded key

Pagina: 1
Acties:

Onderwerpen

Vraag


Acties:
  • 0 Henk 'm!

  • Jean B
  • Registratie: December 2018
  • Laatst online: 07-07 13:04
Ik heb een oude webshop op basis van classis ASP die ik wil gebruiken met omnikassa 2 maar het lukt me niet om een script te vinden dat HMAC512SHA encryptie voor me kan doen met een Base64 encoded key.
De shop is gebouwd in VBscript en ik heb wel wat code kunnen vinden maar deze wil geen Base64 encoded key accepteren. Een script voor de Base64 decoder heb ik.

Dit is de code, volgens mij moet er een aanpassing komen op regel 44 bij de ### marker

<%
' Hash("sha512", "Hello World")
' Hash("sha512HMAC", Array("Hello World", "Shared Key"))

Function Hash(HashType, Target)
On Error Resume Next
Dim PlainText

If IsArray(Target) = True Then PlainText = Target(0) Else PlainText = Target End If

' create UTF-8 string
With CreateObject("ADODB.Stream")
.Open
.CharSet = "Windows-1252"
.WriteText PlainText
.Position = 0
.CharSet = "UTF-8"
PlainText = .ReadText
.Close
End With

Set UTF8Encoding = CreateObject("System.Text.UTF8Encoding")

Dim PlainTextToBytes, BytesToHashedBytes, HashedBytesToHex
PlainTextToBytes = UTF8Encoding.GetBytes_4(PlainText)

Select Case HashType
Case "md5": Set Cryptography = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider") '< 64 (collisions found)
Case "ripemd160": Set Cryptography = CreateObject("System.Security.Cryptography.RIPEMD160Managed")
Case "sha1": Set Cryptography = CreateObject("System.Security.Cryptography.SHA1Managed") '< 80 (collision found)
Case "sha256": Set Cryptography = CreateObject("System.Security.Cryptography.SHA256Managed")
Case "sha384": Set Cryptography = CreateObject("System.Security.Cryptography.SHA384Managed")
Case "sha512": Set Cryptography = CreateObject("System.Security.Cryptography.SHA512Managed")
Case "md5HMAC": Set Cryptography = CreateObject("System.Security.Cryptography.HMACMD5")
Case "ripemd160HMAC": Set Cryptography = CreateObject("System.Security.Cryptography.HMACRIPEMD160")
Case "sha1HMAC": Set Cryptography = CreateObject("System.Security.Cryptography.HMACSHA1")
Case "sha256HMAC": Set Cryptography = CreateObject("System.Security.Cryptography.HMACSHA256")
Case "sha384HMAC": Set Cryptography = CreateObject("System.Security.Cryptography.HMACSHA384")
Case "sha512HMAC": Set Cryptography = CreateObject("System.Security.Cryptography.HMACSHA512")
End Select

Cryptography.Initialize()

###' de onderstaande regel accepteert geen bsae64 decoded string UTF8 encode mag niet
If IsArray(Target) = True Then Cryptography.Key = UTF8Encoding.GetBytes_4(target(1)) End If
BytesToHashedBytes = Cryptography.ComputeHash_2((PlainTextToBytes))

For x = 1 To LenB(BytesToHashedBytes)
HashedBytesToHex = HashedBytesToHex & Right("0" & Hex(AscB(MidB(BytesToHashedBytes, x, 1))), 2)
Next

If Err.Number <> 0 Then Response.Write(Err.Description) Else Hash = LCase(HashedBytesToHex) End If
On Error GoTo 0
End Function
%>

Is er een oude ICT rot die mij hierbij kan helpen

Alle reacties


Acties:
  • +1 Henk 'm!

  • Ravefiend
  • Registratie: September 2002
  • Laatst online: 22-09 16:00

Ravefiend

Carpe diem!

Misschien dat dit je op weg kan helpen:
https://stackoverflow.com...t-in-classic-asp/10198875

Edit: nog wat meer over hetzelfde onderwerp:
https://www.reddit.com/r/...d/generating_a_signature/

[ Voor 30% gewijzigd door Ravefiend op 30-12-2018 08:45 ]


Acties:
  • 0 Henk 'm!

  • Japidoff
  • Registratie: November 2001
  • Laatst online: 25-08 15:54
wat voor foutmelding dan?

base64 is gewoon human readable, en utf8 encode op base64 is een beetje dubbelop?

gang is alles


Acties:
  • 0 Henk 'm!

Verwijderd

Hi - ik heb hetzelfde probleem met een classic asp shop, heb je inmiddels een oplossing gevonden?