Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHK_L] Crypt - ahk cryptography class (Encryption, Hashing)


  • Please log in to reply
83 replies to this topic
jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012
My Script with your Crypt
Posted Image

SKAN's Script:
Posted Image
[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you

TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006
Off the top of my head this is maybe not the best approach but it should work ( AHk_L only ).
Its based off your previous script because you didn't post the new one.
#Include Crypt.ahk
#Include CryptConst.ahk
#Include CryptFoos.ahk
   
#SingleInstance, Force

Gui, Margin, 10, 10
Gui, Font, s10
Gui, Add, GroupBox, x10 y10 w650 h55, Text / Text+Salt
Gui, Add, Edit, x20 y30 w300 vStr gUseStr, AutoHotkey
Gui, Add, Edit, x350 y30 w300 vStr2 gUseStr, Salt
Gui, Add, GroupBox, x10 y85 w650 h55, MD5 / MD5+Salt:
Gui, Add, Edit, x20 y105 w300 vMD5 ReadOnly Lowercase
Gui, Add, Edit, x350 y105 w300 vMD5Salt ReadOnly
Gui, Add, GroupBox, x10 y150 w650 h55, SHA1 / SHA1+Salt:
Gui, Add, Edit, x20 y170 w300 vSHA1   ReadOnly
Gui, Add, Edit, x350 y170 w300 vSHA1Salt ReadOnly
Gui, Add, GroupBox, x10 y215 w650 h55, SHA256 / SHA256+Salt:
Gui, Add, Edit, x20 y235 w300 vSHA256 ReadOnly
Gui, Add, Edit, x350 y235 w300 vSHA256Salt ReadOnly
Gui, Add, GroupBox, x10 y280 w650 h55, SHA384 / SHA384+Salt:
Gui, Add, Edit, x20 y300 w300 vSHA384 ReadOnly
Gui, Add, Edit, x350 y300 w300 vSHA384Salt ReadOnly
Gui, Add, GroupBox, x10 y345 w650 h55, SHA512 / SHA512+Salt:
Gui, Add, Edit, x20 y365 w300 vSHA512 ReadOnly
Gui, Add, Edit, x350 y365 w300 vSHA512Salt ReadOnly

Gui, Add, Text, x20 y405 w300, Verify
Gui, Add, Edit, x20 y435 w490 vVerifyVal 
Gui, Add, Button, x520 y433 w200 vButton gVerify, GO

UseStr:
   GuiControlGet, Str
   GuiControlGet, Str2
   Gui, Show
   GuiControl,,MD5, % Crypt.Hash.StrHash( Str, 1 )
   GuiControl,,MD5Salt, % Crypt.Hash.StrHash( Str, 1, Str2, 7 )
   GuiControl,,SHA1, % Crypt.Hash.StrHash( Str, 3 )
   GuiControl,,SHA1Salt, % Crypt.Hash.StrHash( Str, 3, Str2, 7 )
   GuiControl,,SHA256, % Crypt.Hash.StrHash( Str, 4 )
   GuiControl,,SHA256Salt, % Crypt.Hash.StrHash( Str, 4, Str2, 7 )
   GuiControl,,SHA384, % Crypt.Hash.StrHash( Str, 5 )
   GuiControl,,SHA384Salt, % Crypt.Hash.StrHash( Str, 5, Str2, 7 )
   GuiControl,,SHA512, % Crypt.Hash.StrHash( Str, 6 )
   GuiControl,,SHA512Salt, % Crypt.Hash.StrHash( Str, 6, Str2, 7 )
Return

Verify:
Gui, Submit, NoHide

algo:=[MD5,MD5Salt,SHA1,SHA1Salt,SHA256,SHA256Salt,SHA384,SHA384Salt,SHA512,SHA512Salt]

Loop % algo.maxindex() { [color=#008000]; enum would be cleaner ?[/color]
  GuiControlGet, algName, Name, % algo[A_Index]
  If algo[A_Index] = VerifyVal {
    GuiControl,, Button, % algName " OK"
    Break
  }
  Else
    GuiControl,, Button, VERIFY NOT OK
} 
Return

GuiClose:
GuiEscape:
ExitApp
Perhaps replace my loop with an Enum :?:
Sorry, I couldn't test it right now.

Posted Image

don't duplicate, iterate!


jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012
Can someone help me to get the real HMAC result?

Text: AutoHotkey
HMAC: Test

HMAC Func
SHA1: d6a4f1b43e69f81dc87e3fabad2133c607cd7286
HMAC: e2bc795e12d79930e19c0d08ecd26919cf9c1e76
Posted Image

HMAC with Crypt.ahk
SHA1: d6a4f1b43e69f81dc87e3fabad2133c607cd7286
HMAC: ca0057053d97fa70df59fee32de60a8320701ff0
Posted Image


Crypt.Hash.StrHash(string,HashAlg = 1,pwd = "",hmac_alg = 1)

HashAlg IDs:
1 - MD5
2 - MD2
3 - SHA
4 - SHA_256
5 - SHA_384
6 - SHA_512
--------
CryptAlg and hmac_alg IDs:
1 - RC4
2 - RC2
3 - 3DES
4 - 3DES_112
5 - AES_128
6 - AES_192
7 - AES_256

GuiControl,, SHA1,    % Crypt.Hash.StrHash( Str, 3 )
GuiControl,, SHA1HMAC,  % Crypt.Hash.StrHash( Str, 3, Str2, 7 )

[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you

tlrichar
  • Members
  • 6 posts
  • Last active: Jun 07 2013 02:19 AM
  • Joined: 04 Jun 2013

Ok I'm having an interesting problem with Crypt.ahk. If I complie my application using the Default / x64 compiler then I can perform the following without any problems:

 

hash := Crypt.Hash.FileHash(fileToHash)

 

But if I change the compiler to ANSI (e.g. 32 bit), which I need to use since my script uses some functions that only currently work under a 32 bit environment, then Crypt.Hash.FileHash(fileToHash) returns empty. Why wouldn't this work when compiled as a 32 bit app?



tlrichar
  • Members
  • 6 posts
  • Last active: Jun 07 2013 02:19 AM
  • Joined: 04 Jun 2013

Anyone still monitoring this thread?



tlrichar
  • Members
  • 6 posts
  • Last active: Jun 07 2013 02:19 AM
  • Joined: 04 Jun 2013

So I read at the top of this list (*head smack*) that this needs to be Unicode x32/x64 which is a bit of a problem for me since I have an older function (ConsoleApp.ahk) which requires ANSI x32. So I have two choices... convert this code to ANSI, or convert ConsoleApp to Unicode x32/x64. I've tried the latter without much success.... I don't know if there is a version of this someplace that will work under ANSI x32.... if there is and someone has a link please provide... otherwise I'll keep hammering at this I guess.

 

Thanks,

 

-t



Axel
  • Members
  • 2 posts
  • Last active: May 17 2015 03:55 PM
  • Joined: 16 May 2015

hi evrey body.

After 4 hour i desapointed.

 

I try to use your tools

I use this : http://apathysoftwor...m/ahk/Crypt.zip

But when I would like use the new password generated, the decrypt-function return a wrong word, or nothing.

 

In 1st Time : I use this program for obtain my new password

InputBox, scle, Enter key Password, (your input will be hidden), hide

InputBox, smdp, Enter Password, (your input will be hidden), hide

smdpc := Crypt.Encrypt.StrEncrypt(smdp,scle,5,1)

Run, Notepad.exe

…./….

send, %smdpc%

return

 

In the second time : I copy and past in my file.ahk with this code

smdpc:=my_lettrers_crypted

pwd := Crypt.Encrypt.StrDecrypt(smdpc,scle,5,1)

send, %pwd%

 

but i never obtain my pwd

 

i try more and mor syntaxes in any combination

smdpc:="my_lettrers_crypted"

smdpc=my_lettrers_crypted

smdpc="my_lettrers_crypted"

 

pwd := Crypt.Encrypt.StrDecrypt(%smdpc%,scle,5,1)

pwd := Crypt.Encrypt.StrDecrypt(smdpc,scle,5,1)

send, %pwd%

 

 

So I sorry i have miss somthing and i hope anybody can help me.

 

Great thanks

 

and sorry for my poor english.

 

I work with Seven



jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012

@Axel

for string en- / decriyption try this AES Encryption (String)


[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you

Axel
  • Members
  • 2 posts
  • Last active: May 17 2015 03:55 PM
  • Joined: 16 May 2015

Hi jNizM

 

I ve try test your solution, but I have no chance.

I copy the code https://gist.github....a4b8ec428bf780f

and past in file .ahk

I excute but the result function AES.Decrypt is

Test Str????????

 

I'm not lucky :(

 

 

But in fact with the previus solution i find

In th consol AHK and with th menu View/Variables and their contents

the variable smdpc containt a difernent value that

the commande line

send, %smdpc%

 

in fact, for obtaine the corect encryption, it necessery to use this commande line

sendraw  %smdpc%

 

Now this command lines are restore correct pwd

smdpc=my_lettrers_crypted

pwd := Crypt.Encrypt.StrDecrypt(smdpc,scle,5,1)

sendraw %pwd%

 

But there are a big problem.

In the View/Variables and their contents

it is possible to see the contant of this variable

scle and pwd

 

About the pwd, it simply to add on command line

pwd =

 

But if y would'nt enter at each time the keyvalue in the variable scle

How i can make to hide the value scle

 

Thanks for lot