Mensaje    Asunto: Traducir de Visual Basic Responder citando

Hola amigos,

Necesito traducir un codigo de Visual Basic a Builder, pero no entiendo nada.

Es para generar HASH en SHA1, este es el código:

Imports System.Security.Cryptography

Private Function Codificar(ByVal stringToHash As String) As String

'Dim stringToHash As String
Dim hash As String

Using PrivateKey As RSACryptoServiceProvider = New RSACryptoServiceProvider

'stringToHash = My.Application.CommandLineArgs.Item(0)

'Para verificar a stringToHash num ficheiro
'If Dir(My.Application.Info.DirectoryPath & "\" & "a_codificar" & ".txt") <> "" Then
' Kill(My.Application.Info.DirectoryPath & "\" & "a_codificar" & ".txt")
'End If
'FileOpen(1, My.Application.Info.DirectoryPath & "\" & "a_codificar" & ".txt", OpenMode.Output, OpenAccess.Write)
'PrintLine(1, stringToHash)
'FileClose(1)

'Dim privateKeyTxt As String = System.IO.File.ReadAllText("ChavePrivada.xml")
Dim privateKeyTxt As String = "<RSAKeyValue><Modulus>MIICXQIBAAKBgQDDxNvQnnqhVNfpZt58a4FPeAMRzMz0f78wx584od8q4d3NxzudlyytBqEcAO2na2fn+SmLKBswVtGDCrr1ZH/pK8WPL0Yac2vVXmAzTbFNCfycCiZKQrZdYzF+tV8jRyr+RRTUhRCpAOKynSIuW/oC91ZvSwD88tvS0Wf4VhVuXQIDAQABAoGADjT3DsixdYvGr3V7p+PVWoMHFf+a0BOFOHEEKQP2QhJqGkjfFqyl3Vih0HpwxLmSrM70KNkcQAHM6omYz74fWhfDwFTsIWdZlvW7TxCUEhHtJllYd/g+11fw+6lcOu2FizbJg2xNbQj4RUOppuROizSsQL3kkjrhk51OIJ5F37ECQQD+rlaXrGw/b2MUX2OHMqDvyKuYZAucJZ0UtMUUrlWgV2iqnerslueVb1PfZ/sqMPSnyVNYWDGmxFl/SgLBTTwTAkEAxMhp3HlCXLu64lGCRVtvRz55denKWLA1SKgF73+ypN0ErxhGFHJc9S1Gaj8fR+J9BUyn/0qyyB5x2F/0e6wZzwJBAN8yNItKPbe+S4vAKT6EHUznhZLRIueegzJxVkLQohQaZo0YRpk/iweIgG3K9/A65T7ijpte92yaqYCHgTCdGmcCQQC9QVq+1kiC03Jbc7Tsa5HMXUOHqgAX5/B3HlIHEzOG56I3nAraY1sP2ilcybSV+DfxPtZb60WivdUUGsURpGV1AkAIj1ENXi8CqtLlH5IxFQQ+udMJ9aI119UYyLBYwPyFNLZMhhDGXb1DC22T/5EXl4gcdG4F+kE7j0OyVaXQH6uP</D></RSAKeyValue>"

PrivateKey.FromXmlString(privateKeyTxt)

Dim buffer As Byte() = Encoding.GetEncoding("Windows-1252").GetBytes(stringToHash)
Dim signature As Byte() = PrivateKey.SignData(buffer, "SHA1")

hash = Convert.ToBase64String(signature)

End Using

Return hash

End Function
_________________
Carlos J. Fernandez