hash() function - 2022/11/12 - beta.15

Post your working scripts, libraries and tools.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

hash() function - 2022/11/12 - beta.15

23 Jul 2021, 10:05

Perform hashing of MD2, MD4, MD5, SHA1, SHA256, SHA384, or SHA512.

Input is dynamically detected as a file, string, or buffer object.

Thanks to @jNizM and his CNG lib for AHKv1 which provided many great examples for me getting started.

I plan to add functionality for the rest of the BCrypt suite, but it may be in another lib specifically for encryption / decryption.



The last used algorithm is remembered as well as the last specified item to hash.

Simply call hash() with no params to free all hash objects and the last specified item from memory.

:arrow: Download from GitHub

===========================================================
Updates
===========================================================
Last edited by TheArkive on 12 Nov 2022, 04:34, edited 14 times in total.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: BCryptHash (class and func) - 2021/07/24 - a138

24 Jul 2021, 05:39

Update:
  • added the same functionality as a function
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: BCryptHash (class and func) - 2021/07/25 - beta.1

25 Jul 2021, 03:46

2021/07/25
  • fixed minor oversight in class version, swapped 2 lines
  • tested and working in v2 beta.1
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: BCryptHash (class and func) - 2021/07/25 - beta.1

28 Jan 2022, 06:24

there's an example of a script working? the .ahk I tried to run here from github didn't work
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: BCryptHash (class and func) - 2021/07/25 - beta.1

28 Jan 2022, 07:05

Can you be more specific? What didn't work?

It appears to be working just fine as far as I can see.

Are you trying to hash text? A file? I need more information.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: BCryptHash (class and func) - 2021/07/25 - beta.1

28 Jan 2022, 07:29

@ibieel

I rewrote the example and uploaded the actual example file.

It works. If you have question on how it works, or how to implement it properly, please post a question.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: BCryptHash (class and func) - 2022/01/28 - beta.3

28 Jan 2022, 13:28

2022/01/28
  • class is now defunct and removed
  • the function now remembers the last hashed item, and the last hash algo
  • multiple hash objects can now be stored with the func
  • call hash() to free all hash objects and last hashed item
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: BCryptHash (class and func) - 2021/07/25 - beta.1

30 Jan 2022, 15:33

TheArkive wrote:
28 Jan 2022, 07:29
@ibieel

I rewrote the example and uploaded the actual example file.

It works. If you have question on how it works, or how to implement it properly, please post a question.
hey, I couldn't run any example... I don't know what's going on.
I wanted a script to input a string (a-z && 0-9) and it would return the SHA-256. it's possible?
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 16:11

@ibieel

Can you post the actual code you are using that is not working? For example:

Code: Select all

#Include BCryptHashFunc.ahk

str := "a-z && 0-9"
result := hash(str,"SHA256")

msgbox result

Also, what error are you getting? Please post that also.
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 16:21

TheArkive wrote:
30 Jan 2022, 16:11
@ibieel
Also, what error are you getting? Please post that also.
image.png
image.png (29.44 KiB) Viewed 3191 times
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 16:24

Ok, what text editor are you using?
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 16:27

TheArkive wrote:
30 Jan 2022, 16:24
Ok, what text editor are you using?
https://www.autohotkey.com/scite4ahk/
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 16:28

The code appears to be launched with ahk v1 exe. This is or ahk v2.

I don't use Scite4Ahk, but I do know it is generally setup to use ahk v1 for debugging purposes.
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 16:29

TheArkive wrote:
30 Jan 2022, 16:28
The code appears to be launched with ahk v1 exe. This is or ahk v2.

I don't use Scite4Ahk, but I do know it is generally setup to use ahk v1 for debugging purposes.
do you know how i can change it?
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 16:41

I'm afraid not. I know I can eventually figure it out eventually.

I think there is an AutoHotkey.exe in the SciTE4ahk folder. If you replace it with ahk v2 exe, that should work (save/backup the original)

But I'm not sure if the rest of SciTE4ahk would work as expected. The debugging parts are also written in v1. I'm not sure how using a v2 exe would work with all that.

I would suggest you use Notepad++ with DebugView++

Using a Debugger with any text editor (DebugView/++)

I find this setup to be more flexible and simple when using ahk v1 / v2 ... but ya gotta find our own preference really.

How are you running v2 scripts now normally? Other than in debugging?
User avatar
ibieel
Posts: 216
Joined: 17 Oct 2021, 23:30

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 16:49

TheArkive wrote:
30 Jan 2022, 16:41
I'm afraid not. I know I can eventually figure it out eventually.

I think there is an AutoHotkey.exe in the SciTE4ahk folder. If you replace it with ahk v2 exe, that should work (save/backup the original)

But I'm not sure if the rest of SciTE4ahk would work as expected. The debugging parts are also written in v1. I'm not sure how using a v2 exe would work with all that.

I would suggest you use Notepad++ with DebugView++

Using a Debugger with any text editor (DebugView/++)

I find this setup to be more flexible and simple when using ahk v1 / v2 ... but ya gotta find our own preference really.

How are you running v2 scripts now normally? Other than in debugging?
I only worked with v1 scripts, but I was studying hashing, I searched here on the forum about SHA-256 and I wanted to test your script to learn how it works

I'm kind of confused, but later I'll try to use notepad++.
I have it installed here
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: hash() function - 2022/01/28 - beta.3

30 Jan 2022, 17:07

@ibieel

Do you work with v2 scripts at all?

This little func requires v2 and will not work with v1 at all. Changes need to be made for it to work with v1.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: hash() function - 2022/01/28 - beta.3

31 Jan 2022, 03:58

If you use v1 and v2 like me you need to use the portability of AutoHotkey or use (e.g.) .ah2 as file extension and add reg entries for it.
Or you can still use my v1 version of hashing.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: hash() function - 2022/01/28 - beta.3

31 Jan 2022, 05:27

@ibieel
My OP references jNizM's lib. My small func is based on his lib, already written in v1.
tranht17
Posts: 52
Joined: 03 May 2017, 02:55

Re: hash() function - 2022/01/28 - beta.3

01 Feb 2022, 05:17

I really like your func because it's easy to understand, but it also has a few problems:
* string hash returns wrong value
exam: hash("Hello","SHA1")
=> 7AC231DEBC3AE0E6A5CD9908F681B1D6041E84C2
but it should be
F7FF9E8B7BB2E09B70935A5D785E0CC5D9D0ABF0
* hash(val,"SHA256") ok but hash(,"SHA256") returns wrong value
* Files larger than 4GB are not supported

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: No registered users and 25 guests