Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Excel Hash: Werte verschlüsseln mit SH256

04.12.2019 (­čĹü923)

Excel : Werte kodieren mit HASH funktionen SHA256

Gilt f├╝r Microsoft Excel, Access Word Outlook PowerPoint, Sicher Verschl├╝sseln

Folgende Datei kodiert Texte mit dem SHA256 Hash in verschl├╝sselte Werte.

Hierzu wird in vba Makro der angef├╝gt Code eingef├╝gt.

Man kann dan mit der Excel-Funktion

=get_HASH_SHA256(C6)

Die kodierten Hash Werte in einer neuen Zelle ausgeben

Die Beispiel Datei liegt zum Download bereit im Blog

Input

Encode with HASH SHA256

ABC

b5d4045c3f466fa91fe2cc6abe79232a1a57cdf104f7a26e716e0a1e2789df78

78910

929608f050eae7a40fc1d3614446a69ecb710ae955dee393fbf39c2276c270ea

E123Z

f7db9043f33da0fbbafe41ab99090438e913eb11af05f2aed369abb880c478cf

=get_HASH_SHA256(C6)

Vba Code in Excel

Es werden keine zus├Ątzlichen Verweise ben├Âtigt. In Windows Features muss .NET 3 aktiviert sein

Option Explicit

 

Public Function get_HASH_SHA256(ByVal sInput As String) As String

    get_HASH_SHA256 = SHA256(sInput)

End Function

 

 

Public Function SHA256(sInput As String, Optional bB64 As Boolean = 0) As String

    '----------< SHA256 () >----------

 

    '< setup_Encoders >

    Dim Encoder As Object

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

   

    Dim Encoder_SHA256 As Object

    Set Encoder_SHA256 = CreateObject("System.Security.Cryptography.SHA256Managed")

    '</ setup_Encoders >

   

    '< encode >

    Dim TextToHash() As Byte

    TextToHash = Encoder.GetBytes_4(sInput)

    '</ encode >

 

 

    '*create Byte Arrays

    Dim bytes() As Byte

    bytes = Encoder_SHA256.ComputeHash_2((TextToHash))

 

    '< convert and return >

    If bB64 = True Then

 

        SHA256 = ConvToBase64String(bytes)

    Else

        SHA256 = ConvToHexString(bytes)

    End If

    '</ convert and return >

   

    '< close >

    Set Encoder = Nothing

    Set Encoder_SHA256 = Nothing

    '</ close >

    '----------</ SHA256 () >----------

End Function

 

 

 

 

Public Function ConvToBase64String(vIn As Variant) As Variant

 

    Dim oD As Object

     

    Set oD = CreateObject("MSXML2.DOMDocument")

      With oD

        .LoadXML "<root />"

        .DocumentElement.DataType = "bin.base64"

        .DocumentElement.nodeTypedValue = vIn

    End With

    ConvToBase64String = Replace(oD.DocumentElement.Text, vbLf, "")

   

    Set oD = Nothing

 

End Function

 

Public Function ConvToHexString(vIn As Variant) As Variant

 

    Dim oD As Object

     

    Set oD = CreateObject("MSXML2.DOMDocument")

     

      With oD

        .LoadXML "<root />"

        .DocumentElement.DataType = "bin.Hex"

        .DocumentElement.nodeTypedValue = vIn

    End With

    ConvToHexString = Replace(oD.DocumentElement.Text, vbLf, "")

   

    Set oD = Nothing

 

End Function