- 2025-07-28 1.0.11 Se modifica funcion SHA256 para que no use métodos obsoletos y para que admita un encoding diferente a unicode
This commit is contained in:
23
crypt.vb
23
crypt.vb
@@ -101,26 +101,29 @@ Public Class crypt
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function SHA256(ByVal Datos() As Byte) As String
|
Public Shared Function SHA256(ByVal Datos() As Byte) As String
|
||||||
Dim sha256Obj As New Security.Cryptography.SHA256CryptoServiceProvider
|
Using sha256Obj As Security.Cryptography.SHA256 = Security.Cryptography.SHA256.Create()
|
||||||
Dim bytesToHash() As Byte = Datos
|
Dim bytesToHash() As Byte = sha256Obj.ComputeHash(Datos)
|
||||||
bytesToHash = sha256Obj.ComputeHash(bytesToHash)
|
|
||||||
Dim strResult As String = ""
|
Dim strResult As String = ""
|
||||||
For Each b As Byte In bytesToHash
|
For Each b As Byte In bytesToHash
|
||||||
strResult += b.ToString("x2")
|
strResult += b.ToString("x2")
|
||||||
Next
|
Next
|
||||||
Return strResult.ToUpper
|
Return strResult.ToUpper()
|
||||||
|
End Using
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function SHA256(ByVal Cadena As String) As String
|
Public Shared Function SHA256(ByVal Cadena As String, Optional ByVal encoding As System.Text.Encoding = Nothing) As String
|
||||||
Dim sha256Obj As New Security.Cryptography.SHA256CryptoServiceProvider
|
Using sha256Obj As Security.Cryptography.SHA256 = Security.Cryptography.SHA256.Create()
|
||||||
Dim Datos() As Byte = System.Text.Encoding.Unicode.GetBytes(Cadena)
|
If encoding Is Nothing Then
|
||||||
Dim bytesToHash() As Byte = Datos
|
encoding = System.Text.Encoding.Unicode
|
||||||
bytesToHash = sha256Obj.ComputeHash(bytesToHash)
|
End If
|
||||||
|
Dim Datos() As Byte = encoding.GetBytes(Cadena)
|
||||||
|
Dim bytesToHash() As Byte = sha256Obj.ComputeHash(Datos)
|
||||||
Dim strResult As String = ""
|
Dim strResult As String = ""
|
||||||
For Each b As Byte In bytesToHash
|
For Each b As Byte In bytesToHash
|
||||||
strResult += b.ToString("x2")
|
strResult += b.ToString("x2")
|
||||||
Next
|
Next
|
||||||
Return strResult.ToUpper
|
Return strResult.ToUpper()
|
||||||
|
End Using
|
||||||
End Function
|
End Function
|
||||||
Public Shared Function ObtenerCadenaHashSHA256AportandoSal(ByVal cadenaQueQuieroHashear As String, ByVal sal As String)
|
Public Shared Function ObtenerCadenaHashSHA256AportandoSal(ByVal cadenaQueQuieroHashear As String, ByVal sal As String)
|
||||||
Dim sb As Text.StringBuilder = New Text.StringBuilder()
|
Dim sb As Text.StringBuilder = New Text.StringBuilder()
|
||||||
|
|||||||
@@ -16,11 +16,12 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<PackageId>tsUtilidades</PackageId>
|
<PackageId>tsUtilidades</PackageId>
|
||||||
<PackageTags>net8.0, libreria</PackageTags>
|
<PackageTags>net8.0, libreria</PackageTags>
|
||||||
<Version>1.0.10</Version>
|
<Version>1.0.11</Version>
|
||||||
<Authors>Manuel</Authors>
|
<Authors>Manuel</Authors>
|
||||||
<Company>Tecnosis S.A</Company>
|
<Company>Tecnosis S.A</Company>
|
||||||
<Description>Utilidades Varias</Description>
|
<Description>Utilidades Varias</Description>
|
||||||
<PackageReleaseNotes>
|
<PackageReleaseNotes>
|
||||||
|
- 2025-07-28 1.0.11 Se modifica funcion SHA256 para que no use métodos obsoletos y para que admita un encoding diferente a unicode
|
||||||
- 2025-07-28 1.0.10 Nueva función DescomponerCNsuscriptor
|
- 2025-07-28 1.0.10 Nueva función DescomponerCNsuscriptor
|
||||||
- 2025-07-28 1.0.9 Correccion ObtenerValorDesdeNombre
|
- 2025-07-28 1.0.9 Correccion ObtenerValorDesdeNombre
|
||||||
- 2025-07-28 1.0.8 Correccion ObtenerValorDesdeNombre
|
- 2025-07-28 1.0.8 Correccion ObtenerValorDesdeNombre
|
||||||
|
|||||||
Reference in New Issue
Block a user