-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathMD5_2.ahk
120 lines (91 loc) · 3.41 KB
/
MD5_2.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
###############################################
Encrypt() - Password protected Text Encryption
by Avi Aryan
v 0.6
#############################
FEATURES
* SAME KEY (PASSWORD) FOR ENCRYPTION AND DECRYPTION
* ENCRYPTED STRING IS POWERFUL BUT OF SAME SIZE AS STRING
* PASSWORDS CAN BE CASE-SENSITIVE AND ALPHA NUMERIC THUS SECURE AND EASY TO REMEMBER
* STRING'S CASE IS CONSERVED THROUGH THE PROCESS
NOTES
* Max Pass Length = 30 characters
PLEASE SEE
* Requires Scientific Maths lib
* The Crypt algorithm changes with version. So, the function stores version number in the encrypted text (from v0.3) and notifies you when you are using a
older/newer version for decryption.
Version History - https://github.com/avi-aryan/Avis-Autohotkey-Repo/commits/master/Functions/Encrypt.ahk
*/
/*
msgbox,% var1 := Encrypt("AutoHotkey_l", "lexikos")
msgbox,% Decrypt(var1, "lexIkos") ;<--- Password problem. I is capital in lexikos
msgbox,% Decrypt(var1, "lexiko") ;<--- s missing and you r dead
msgbox,% Decrypt(var1, "lexikos") ;<--- Perfect password , perfect result
*/
Encrypt(text, password){
return Crypt(text, password)
}
Decrypt(text, password){
if ( Substr(text, -1) != "06" ) {
; msgbox, 16, Encrypt(),% "The text is encrypted using version " Substr(text,-1,1) "." Substr(text,0,1) "`nUse that version to decrypt."
return
}
else text := Substr(text, 1, -2)
return Crypt(text, password, 0)
}
;Crypt()
; Performs encryption and decryption
Crypt(text, password, mode=1) {
oldcase := A_StringCaseSense
StringCaseSense, On
letters := "abcdefghijklmnopqrstuvwxyz0123456789-,. @!?/:;()" ;48 . no limit here but still
parsedlist := PassCrypt(password, letters, convindex, carryindex) "ABCDEFGHIJKLMOPQRSTUVWXYZ"
letters .= "ABCDEFGHIJKLMOPQRSTUVWXYZ"
Loop
{
if mode
toreturn .= Crypt_Replace(letters, parsedlist, Substr(text, 1, convindex))
else
toreturn .= Crypt_Replace(parsedlist, letters, Substr(text, 1, convindex))
parsedlist := Substr(parsedlist, 1-carryindex) SubStr(parsedlist, 1, -1*carryindex)
text := Substr(text, convindex+1)
if ( text == "" )
{
StringCaseSense, %oldcase%
return mode ? toreturn "06" : toreturn ;04 is version . Not using a global
}
}
}
;PassCrypt()
; Generates Random sequence from a password
PassCrypt(password, letters, Byref convindex, Byref carryindex){
alphalist := Substr(letters, 1, 26)
loop,parse,alphalist
StringReplace,password,password,%A_loopfield%,%A_index%,All ;Convert to numeric format
StringUpper,alphalist,alphalist
loop,parse,alphalist
StringReplace,password,password,%A_loopfield%,% A_index+26, All
convindex := Substr(password, 1, 1) , carryindex := ( Substr(password, 0) == "0" ) ? 1 : Substr(password, 0)
return SM_uniquePMT(letters, password, "|")
}
;Crypt_Replace()
; Responsible for Find and Replace
Crypt_Replace(baselist, parsedlist, text){
reschars := "¢¤¥¦§©ª«®µ¶"
loop, parse, reschars
if !Instr(text, A_LoopField) {
conv_char := A_LoopField
break
}
loop, parse, baselist
StringReplace,text,text,%A_loopfield%,%A_loopfield%%conv_char%,All ;a_
loop, parse, parsedlist
{
from_baselist := Substr(baselist, A_index, 1)
StringReplace,text,text,%from_baselist%%conv_char%,%A_LoopField%,All
}
return text
}
#Include, %A_ScriptDir%\Functions\Maths.ahk
;----------------------------------------------------------------------- X -------------------------------------------------------------------------------