+ Reply to Thread
Results 1 to 17 of 17

Hashing in Excel

Hybrid View

  1. #1
    Registered User
    Join Date
    11-10-2015
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office 2010
    Posts
    8

    Question Hashing in Excel

    Hi all,

    I was wondering if there's a way to perform hashes in excel 2011 (MAC), specifically MD4, MD5, and sha256?

    All the threads I found on the subject were from 2011, locked, or had outdated links and information.

    Thanks in advance for your help!

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,418

    Re: Hashing in Excel

    I put "hashing in Excel" into my favroite internet search engine and found many workable links and discussions. This one might be of particular interest: http://web.archive.org/web/200805260...eecode.htm#md5
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    11-10-2015
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Hashing in Excel

    Quote Originally Posted by MrShorty View Post
    I put "hashing in Excel" into my favroite internet search engine and found many workable links and discussions. This one might be of particular interest: http://web.archive.org/web/200805260...eecode.htm#md5
    Thanks a ton. I'll go through this

  4. #4
    Registered User
    Join Date
    11-10-2015
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Hashing in Excel

    Update:

    I downloaded files from the link you gave, and there's code present in the HTML files which I believe is VB. I tried copy-pasting the code (No VB experience, I'm afraid ) and couldn't get it to work. I tried defining it as a macro as well but to no avail.

    The particular files in question were the 'sha256 digest' and 'MD5 digest' zips.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,418

    Re: Hashing in Excel

    It is too bad that you have no VB experience, because it seems that the Frez link I posted is intended for those with significant VB experience. Since I do not have any experience with class modules (or otherwise trying to import stand-alone VB code into VBA for applications), I'm not sure how to import this code into Excel, either. Perhaps someone will come along who is more experienced with VB and help you import this into your VBA installation.

    Have you tried other internet searches? I have to believe that you are not the first person ever to want to hash data in Excel, and that someone somewhere has done it before.

    I tried "md5 algorithm in Excel" in my favorite internet search engine and, among others, found this http://softwaretopic.informer.com/md5-algorithm-in-vba/ perhaps one of these will be easier for someone with no VB experience to use.

    (At the same time, I'm starting to feel like a professional internet searcher. It seems like it would save us both time if you were putting these search terms into your own favorite internet search engine and wading through the many hits yourself.)

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Hashing in Excel

    Do you particularly need one of those hashing schemes, or would CRC32 do?
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Registered User
    Join Date
    11-10-2015
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Hashing in Excel

    It's the aforementioned hashes in particular that I need, sorry.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Hashing in Excel

    From the link:
    Sub test()
    
        Dim md5Hash As MD5
        Set md5Hash = New MD5
        
        Debug.Print "MD5", md5Hash.MD5("Kyle")
        
        
        Dim sha256Hash As SHA256
        Set sha256Hash = New SHA256
        
        Debug.Print "SHA256", sha256Hash.SHA256("Kyle")
    
    End Sub
    Outputs:
    MD5           e8b579fe36f15209c6f167396a46b04e
    SHA256        b9ecfab5789d7b96f8765c147fff488e9946ede2797a4ec149c2cc5b35054799
    Which is correct, to use, simply download the sha256 & md5 zips, extract the cls files and copy and paste each into a new class module (you could import them too). Copy down from the beginning of the starred comment line (you don't need the stuff before). I've called the classes MD5 and SHA256 in the above, but you may name them whatever you like.

    Or since this works quite neatly with an interface, I'd be tempted to (knock one up and) simply use:
    Sub test()
    
        Dim hash As IHash
        Set hash = New MD5
        
        Debug.Print "MD5", hash.hash("Kyle")
        
        Set hash = New SHA256
        
        Debug.Print "SHA256", hash.hash("Kyle")
    
    End Sub
    Last edited by Kyle123; 11-17-2015 at 12:09 PM.

  9. #9
    Registered User
    Join Date
    11-10-2015
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Hashing in Excel

    Thanks, Kyle. I have imported the files as such:

    Screen Shot 2015-11-18 at 13.49.03.png

    How would I go about having one column of strings populate a separate column with a hash of those values?

    Thanks again

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Hashing in Excel

    Please upload a sample workbook

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  11. #11
    Registered User
    Join Date
    11-10-2015
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Hashing in Excel

    Morning, here's a sample workbook.

    HashingExample.xls

    I'm trying to set up things so that the input column automatically generates the MD4, MD5, and Sha256 hashes into 3 other columns. I have imported the class files across but I'm unsure what to do with them. As of this point I've yet to locate a MD4 .cls file. Once I understand how the other two are used I should be fine and can set out looking for one.

    Thanks in advance.

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Hashing in Excel

    You haven't imported them properly, delete everything above the green comment text. So the top of each class looks like this (obviously different for the SHA version):
    '*******************************************************************************
    ' MODULE:       CMD5
    ' FILENAME:     C:\My Code\vb\md5\CMD5.cls
    ' AUTHOR:       Phil Fresle
    ' CREATED:      16-Feb-2001
    ' COPYRIGHT:    Copyright 2001 Frez Systems Limited. All Rights Reserved.
    '
    Then in a standard module:
    Public Function MD5(s As String) As String
    
        Static md5Hash As CMD5
        If md5Hash Is Nothing Then Set md5Hash = New CMD5
        
        MD5 = md5Hash.MD5(s)
        
    End Function
    Public Function SHA256(s As String) As String
    
        Static sha256Hash As CSHA256
        If sha256Hash Is Nothing Then Set sha256Hash = New CSHA256
        
        SHA256 = sha256Hash.SHA256(s)
        
    End Function
    Then in D4:
    =SHA256(B4)
    I4:
    =MD5(B4)

  13. #13
    Registered User
    Join Date
    11-10-2015
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Hashing in Excel

    Okay, I've done that, I think. I removed the text above the screen content and both class files start as you specified.

    The functions show up in predictive text for cells, but the algorithm simply returns #REF! though.

    HashingExample.xls

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Hashing in Excel

    It must be something with your computer, your workbook works fine for me. Your formulas looked weird, they showed as:
    =#Ref(B4)
    But once I'd changed them to the correct names, everything works as expected

  15. #15
    Registered User
    Join Date
    11-10-2015
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Office 2010
    Posts
    8

    Re: Hashing in Excel

    I'm inputting the correct names but they return #REF!. If I exit and reopen the workbook the inputs change to #REF! as well. I've tried saving it as .xlsm but there's been no change to this issue

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Hashing in Excel

    Does it work on a windows version?

  17. #17
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,418

    Re: Hashing in Excel

    Is it possibly the same issue as this one: http://www.excelforum.com/excel-form...ml#post4170502 Since SHA256 is a valid cell reference in 2007+, having named your UDF SHA256, you are creating a naming conflict that Excel does not handle correctly. Try renaming your UDF's to something that does not look like a cell reference.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Hashing
    By Starting vba programmer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-27-2005, 05:15 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1