Convert hash code(AES Input) to string(output) using VB.net code

Hi All,

I want to convert hash code (AES input text) to string (output text) and use the output text in further process. I need to do this in VB.net code.

Note : I have used cryptography activities working fine but as per my organization we need to use vb.net code only to convert that.

I am new to converting this using VB.net code. Could someone help me in writing the code?

@Palaniyappan @loginerror @Lahiru.Fernando @Pablito @balupad14 @balkishan @Jan_Brian_Despi @HareeshMR

@satishmypudi

You can try this

Dim keyBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(SecretKey)
Dim hashBytes As Byte() = System.Convert.FromBase64String(InputHash)

Dim aes As System.Security.Cryptography.Aes = System.Security.Cryptography.Aes.Create()
aes.Key = keyBytes
aes.GenerateIV()

Dim decryptor As System.Security.Cryptography.ICryptoTransform = aes.CreateDecryptor()
Dim plainTextBytes As Byte() = New Byte(hashBytes.Length - 1) {}
Using ms As New System.IO.MemoryStream(hashBytes)
    Using cs As New System.Security.Cryptography.CryptoStream(ms, decryptor, System.Security.Cryptography.CryptoStreamMode.Read)
        cs.Read(plainTextBytes, 0, plainTextBytes.Length)
    End Using
End Using
plainText = System.Text.Encoding.UTF8.GetString(plainTextBytes)

cheers

1 Like

Thanks for the quick response here @Anil_G. I will implement this and let you know the results.

1 Like

Hi @Anil_G can you provide me sample input that needs to be given for input hash argument
because whatever the hash code i am giving is throwing below error. As i cannot provide my organization data here, requesting you to provide me sample input if possible.

@satishmypudi

First of confirm which encoding is being used I am using UTF-8 as you can see…while generating if the encoding is different for that then we need to change that parameter accordingly

cheers

hey @Anil_G

I am not pretty sure which encoding they’ve used because it is directly coming from a website when we download the particular file. So giving you sample hash code may be if you can analyze which encoding they’ve did.

Note: I’ve removed some of the length of this below string for security purposes, it was somewhat lengthy hash string than shown image.

image

Let me know if you can able to identify else i will have a word with my team.

Thanks

@satishmypudi

Ideally they would be the better people to give you the info

You need the encoding …

The secret key they use

And the if any specific iv they are using…I created an Iv random in it

Cheers

yeah @Anil_G, I do have secret key but I am unable to get the encoding. let me check with them.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.