7 Commits
Author SHA1 Message Date
Andreas Bail f5f65ab030 yeet tests and libcrypt 2026-08-20 15:54:24 +02:00
Andreas Bail dcb33d6924 rename and gitignore additions 2026-08-20 14:24:56 +02:00
Andreas Bail a5829eebc4 fix Fileinstall 2026-07-29 10:46:04 +02:00
Andreas Bail 656ecd911e move in noodles & add icon states 2026-07-27 12:32:11 +02:00
Andreas Bail 8888407d28 add off state icon 2026-07-27 12:31:45 +02:00
Andreas Bail a37de18e85 rename icon 2026-07-27 12:31:17 +02:00
Andreas Bail b55ff78230 add noodles 2026-07-27 11:17:59 +02:00
9 changed files with 3470 additions and 96 deletions
-96
View File
@@ -1,96 +0,0 @@
#Requires AutoHotkey v2.0
#SingleInstance Force
Persistent
CorrectPassword := "Kaffeebohne"
result := InputBox(
"Bitte Passwort eingeben:",
"Authentifizierung",
"Password w200 h90"
)
if (result.Result != "OK") {
ExitApp()
}
if (result.Value != CorrectPassword) {
MsgBox("Falsches Passwort!", "Fehler", "Iconx")
ExitApp()
}
global IdleTime := 240 ; seconds
global Enabled := true
global LastX := 0
global LastY := 0
global LastMoveTime := A_TickCount
MouseGetPos &LastX, &LastY
; Create tray menu
A_TrayMenu.Delete()
A_TrayMenu.Add("Enabled", ToggleEnabled)
A_TrayMenu.Add()
A_TrayMenu.Add("Set idle time...", SetIdleTime)
A_TrayMenu.Add()
A_TrayMenu.Add("Exit", (*) => ExitApp())
UpdateTray()
; Check mouse every second
SetTimer(CheckMouse, 20000)
; ----------------------
CheckMouse() {
global Enabled, IdleTime, LastX, LastY, LastMoveTime
if !Enabled
return
MouseGetPos &x, &y
if (x != LastX || y != LastY) {
LastX := x
LastY := y
LastMoveTime := A_TickCount
return
}
if (A_TickCount - LastMoveTime >= IdleTime * 1000) {
MouseMove x + 1, y, 0
MouseMove x, y, 0
LastMoveTime := A_TickCount
}
}
ToggleEnabled(*) {
global Enabled
Enabled := !Enabled
UpdateTray()
}
SetIdleTime(*) {
global IdleTime
result := InputBox("Enter idle time in seconds:", "Mouse mover settings", "w200 h90", IdleTime)
if result.Result = "OK" && IsNumber(result.Value) {
IdleTime := Integer(result.Value)
}
}
UpdateTray() {
global Enabled
if Enabled {
A_TrayMenu.Check("Enabled")
A_IconTip := "Mouse Mover - Active"
} else {
A_TrayMenu.Uncheck("Enabled")
A_IconTip := "Mouse Mover - Disabled"
}
}
+121
View File
@@ -0,0 +1,121 @@
#Requires AutoHotkey v2.0
#SingleInstance Force
Persistent
FileInstall("akfe-on.ico", A_Temp "\akfe-on.ico", 1)
FileInstall("akfe-off.ico", A_Temp "\akfe-off.ico", 1)
global IdleTime := 240 ; seconds
global Enabled := true
global LastX := 0
global LastY := 0
global LastMoveTime := A_TickCount
MouseGetPos &LastX, &LastY
;=========================================================
; Tray menu
;=========================================================
A_TrayMenu.Delete()
A_TrayMenu.Add("Enabled", ToggleEnabled)
A_TrayMenu.Add("Set idle time...", SetIdleTime)
A_TrayMenu.Add()
; Copypasta submenu
CopyMenu := Menu()
CopyMenu.Add("Standardpasswort", SetClipboard.Bind("BitteÄndern!"))
CopyMenu.Add("Password Ticket", SetClipboard.Bind("Auf Standardpasswort zurückgesetzt."))
CopyMenu.Add("Berechtigt", SetClipboard.Bind("Berechtigung erteilt."))
CopyMenu.Add("Erledigt", SetClipboard.Bind("Erledigt."))
A_TrayMenu.Add("Noodle", CopyMenu)
A_TrayMenu.Add()
A_TrayMenu.Add("Exit", (*) => ExitApp())
TraySetIcon(A_Temp "\akfe-on.ico")
UpdateTray()
SetTimer(CheckMouse, 20000)
OnMessage(0x404, TrayIconHandler)
;=========================================================
; Mouse mover
;=========================================================
CheckMouse() {
global Enabled, IdleTime, LastX, LastY, LastMoveTime
if !Enabled
return
MouseGetPos &x, &y
if (x != LastX || y != LastY) {
LastX := x
LastY := y
LastMoveTime := A_TickCount
return
}
if (A_TickCount - LastMoveTime >= IdleTime * 1000) {
MouseMove x + 1, y, 0
MouseMove x, y, 0
LastMoveTime := A_TickCount
}
}
TrayIconHandler(wParam, lParam, msg, hwnd)
{
; Double left click on tray icon
if (lParam = 0x203) {
ToggleEnabled()
}
}
;=========================================================
; Tray functions
;=========================================================
ToggleEnabled(*) {
global Enabled
Enabled := !Enabled
UpdateTray()
}
SetIdleTime(*) {
global IdleTime
result := InputBox("Enter idle time in seconds:", "Mouse mover settings", "w200 h90", IdleTime)
if result.Result = "OK" && IsNumber(result.Value) {
IdleTime := Integer(result.Value)
}
}
UpdateTray() {
global Enabled
if Enabled {
TraySetIcon(A_Temp "\akfe-on.ico")
A_TrayMenu.Check("Enabled")
A_IconTip := "ArteKaffee - Active"
} else {
TraySetIcon(A_Temp "\akfe-off.ico")
A_TrayMenu.Uncheck("Enabled")
A_IconTip := "ArteKaffee - Disabled"
}
}
;=========================================================
; Clipboard
;=========================================================
SetClipboard(txt, *) {
A_Clipboard := txt
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 125 KiB

+932
View File
@@ -0,0 +1,932 @@
LC_Version := "0.0.21.01"
LC_ASCII2Bin(s,pretty:=0) {
r:=""
Loop, % l:=StrLen(s)
{
z:=Asc(SubStr(s,A_Index,1)),y:="",p:=1
Loop, 8
b:=!!(z&p),y:=b y,p:=p<<1
r.=y
if (pretty && (A_Index<l))
r.=" "
}
return r
}
LC_Ascii2Bin2(Ascii) {
for each, Char in StrSplit(Ascii)
Loop, 8
Out .= !!(Asc(Char) & 1 << 8-A_Index)
return Out
}
LC_Bin2Ascii(Bin) {
Bin := RegExReplace(Bin, "[^10]")
Loop, % StrLen(Bin) / 8
{
for each, Bit in StrSplit(SubStr(Bin, A_Index*8-7, 8))
Asc += Asc + Bit
Out .= Chr(Asc), Asc := 0
}
return Out
}
LC_BinStr_EncodeText(Text, Pretty=False, Encoding="UTF-8") {
VarSetCapacity(Bin, StrPut(Text, Encoding))
LC_BinStr_Encode(BinStr, Bin, StrPut(Text, &Bin, Encoding)-1, Pretty)
return BinStr
}
LC_BinStr_DecodeText(Text, Encoding="UTF-8") {
Len := LC_BinStr_Decode(Bin, Text)
return StrGet(&Bin, Len, Encoding)
}
LC_BinStr_Encode(ByRef Out, ByRef In, InLen, Pretty=False) {
Loop, % InLen
{
Byte := NumGet(In, A_Index-1, "UChar")
Loop, 8
Out .= Byte>>(8-A_Index) & 1
if Pretty ; Perhaps a regex at the end instead of a check in every loop would be better
Out .= " "
}
; Out := RegExReplace(Out, "(\d{8})", "$1 ") ; For example, this
}
LC_BinStr_Decode(ByRef Out, ByRef In) {
ByteCount := StrLen(In)/8
VarSetCapacity(Out, ByteCount, 0)
BitIndex := 1
Loop, % ByteCount
{
Byte := 0
Loop, 8
Byte := Byte<<1 | SubStr(In, BitIndex++, 1)
NumPut(Byte, Out, A_Index-1, "UChar")
}
}
LC_Base64_EncodeText(Text,Encoding="UTF-8")
{
VarSetCapacity(Bin, StrPut(Text, Encoding))
LC_Base64_Encode(Base64, Bin, StrPut(Text, &Bin, Encoding)-1)
return Base64
}
LC_Base64_DecodeText(Text,Encoding="UTF-8")
{
Len := LC_Base64_Decode(Bin, Text)
return StrGet(&Bin, Len, Encoding)
}
LC_Base64_Encode(ByRef Out, ByRef In, InLen)
{
return LC_Bin2Str(Out, In, InLen, 0x40000001)
}
LC_Base64_Decode(ByRef Out, ByRef In)
{
return LC_Str2Bin(Out, In, 0x1)
}
LC_Bin2Hex(ByRef Out, ByRef In, InLen, Pretty=False)
{
return LC_Bin2Str(Out, In, InLen, Pretty ? 0xb : 0x4000000c)
}
LC_Hex2Bin(ByRef Out, ByRef In)
{
return LC_Str2Bin(Out, In, 0x8)
}
LC_Bin2Str(ByRef Out, ByRef In, InLen, Flags)
{
DllCall("Crypt32.dll\CryptBinaryToString", "Ptr", &In
, "UInt", InLen, "UInt", Flags, "Ptr", 0, "UInt*", OutLen)
VarSetCapacity(Out, OutLen * (1+A_IsUnicode))
DllCall("Crypt32.dll\CryptBinaryToString", "Ptr", &In
, "UInt", InLen, "UInt", Flags, "Str", Out, "UInt*", OutLen)
return OutLen
}
LC_Str2Bin(ByRef Out, ByRef In, Flags)
{
DllCall("Crypt32.dll\CryptStringToBinary", "Ptr", &In, "UInt", StrLen(In)
, "UInt", Flags, "Ptr", 0, "UInt*", OutLen, "Ptr", 0, "Ptr", 0)
VarSetCapacity(Out, OutLen)
DllCall("Crypt32.dll\CryptStringToBinary", "Ptr", &In, "UInt", StrLen(In)
, "UInt", Flags, "Str", Out, "UInt*", OutLen, "Ptr", 0, "Ptr", 0)
return OutLen
}
;
; Version: 2014.03.06-1518, jNizM
; see https://en.wikipedia.org/wiki/Caesar_cipher
; ===================================================================================
LC_Caesar(string, num := 2) {
ret := c := ""
loop, parse, string
{
c := Asc(A_LoopField)
if (c > 64) && (c < 91)
ret .= Chr(Mod(c - 65 + num, 26) + 65)
else if (c > 96) && (c < 123)
ret .= Chr(Mod(c - 97 + num, 26) + 97)
else
ret .= A_LoopField
}
return ret
}
LC_CalcAddrHash(addr, length, algid, byref hash = 0, byref hashlength = 0) {
static h := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "a", "b", "c", "d", "e", "f"]
static b := h.minIndex()
hProv := hHash := o := ""
if (DllCall("advapi32\CryptAcquireContext", "Ptr*", hProv, "Ptr", 0, "Ptr", 0, "UInt", 24, "UInt", 0xf0000000))
{
if (DllCall("advapi32\CryptCreateHash", "Ptr", hProv, "UInt", algid, "UInt", 0, "UInt", 0, "Ptr*", hHash))
{
if (DllCall("advapi32\CryptHashData", "Ptr", hHash, "Ptr", addr, "UInt", length, "UInt", 0))
{
if (DllCall("advapi32\CryptGetHashParam", "Ptr", hHash, "UInt", 2, "Ptr", 0, "UInt*", hashlength, "UInt", 0))
{
VarSetCapacity(hash, hashlength, 0)
if (DllCall("advapi32\CryptGetHashParam", "Ptr", hHash, "UInt", 2, "Ptr", &hash, "UInt*", hashlength, "UInt", 0))
{
loop % hashlength
{
v := NumGet(hash, A_Index - 1, "UChar")
o .= h[(v >> 4) + b] h[(v & 0xf) + b]
}
}
}
}
DllCall("advapi32\CryptDestroyHash", "Ptr", hHash)
}
DllCall("advapi32\CryptReleaseContext", "Ptr", hProv, "UInt", 0)
}
return o
}
LC_CalcStringHash(string, algid, encoding = "UTF-8", byref hash = 0, byref hashlength = 0) {
chrlength := (encoding = "CP1200" || encoding = "UTF-16") ? 2 : 1
length := (StrPut(string, encoding) - 1) * chrlength
VarSetCapacity(data, length, 0)
StrPut(string, &data, floor(length / chrlength), encoding)
return LC_CalcAddrHash(&data, length, algid, hash, hashlength)
}
LC_CalcHexHash(hexstring, algid) {
length := StrLen(hexstring) // 2
VarSetCapacity(data, length, 0)
loop % length
{
NumPut("0x" SubStr(hexstring, 2 * A_Index - 1, 2), data, A_Index - 1, "Char")
}
return LC_CalcAddrHash(&data, length, algid)
}
LC_CalcFileHash(filename, algid, continue = 0, byref hash = 0, byref hashlength = 0) {
fpos := ""
if (!(f := FileOpen(filename, "r")))
{
return
}
f.pos := 0
if (!continue && f.length > 0x7fffffff)
{
return
}
if (!continue)
{
VarSetCapacity(data, f.length, 0)
f.rawRead(&data, f.length)
f.pos := oldpos
return LC_CalcAddrHash(&data, f.length, algid, hash, hashlength)
}
hashlength := 0
while (f.pos < f.length)
{
readlength := (f.length - fpos > continue) ? continue : f.length - f.pos
VarSetCapacity(data, hashlength + readlength, 0)
DllCall("RtlMoveMemory", "Ptr", &data, "Ptr", &hash, "Ptr", hashlength)
f.rawRead(&data + hashlength, readlength)
h := LC_CalcAddrHash(&data, hashlength + readlength, algid, hash, hashlength)
}
return h
}
LC_CRC32(string, encoding = "UTF-8") {
chrlength := (encoding = "CP1200" || encoding = "UTF-16") ? 2 : 1
length := (StrPut(string, encoding) - 1) * chrlength
VarSetCapacity(data, length, 0)
StrPut(string, &data, floor(length / chrlength), encoding)
hMod := DllCall("Kernel32.dll\LoadLibrary", "Str", "Ntdll.dll")
SetFormat, Integer, % SubStr((A_FI := A_FormatInteger) "H", 0)
CRC32 := DllCall("Ntdll.dll\RtlComputeCrc32", "UInt", 0, "UInt", &data, "UInt", length, "UInt")
CRC := SubStr(CRC32 | 0x1000000000, -7)
DllCall("User32.dll\CharLower", "Str", CRC)
SetFormat, Integer, %A_FI%
return CRC, DllCall("Kernel32.dll\FreeLibrary", "Ptr", hMod)
}
LC_HexCRC32(hexstring) {
length := StrLen(hexstring) // 2
VarSetCapacity(data, length, 0)
loop % length
{
NumPut("0x" SubStr(hexstring, 2 * A_Index -1, 2), data, A_Index - 1, "Char")
}
hMod := DllCall("Kernel32.dll\LoadLibrary", "Str", "Ntdll.dll")
SetFormat, Integer, % SubStr((A_FI := A_FormatInteger) "H", 0)
CRC32 := DllCall("Ntdll.dll\RtlComputeCrc32", "UInt", 0, "UInt", &data, "UInt", length, "UInt")
CRC := SubStr(CRC32 | 0x1000000000, -7)
DllCall("User32.dll\CharLower", "Str", CRC)
SetFormat, Integer, %A_FI%
return CRC, DllCall("Kernel32.dll\FreeLibrary", "Ptr", hMod)
}
LC_FileCRC32(sFile := "", cSz := 4) {
Bytes := ""
cSz := (cSz < 0 || cSz > 8) ? 2**22 : 2**(18 + cSz)
VarSetCapacity(Buffer, cSz, 0)
hFil := DllCall("Kernel32.dll\CreateFile", "Str", sFile, "UInt", 0x80000000, "UInt", 3, "Int", 0, "UInt", 3, "UInt", 0, "Int", 0, "UInt")
if (hFil < 1)
{
return hFil
}
hMod := DllCall("Kernel32.dll\LoadLibrary", "Str", "Ntdll.dll")
CRC32 := 0
DllCall("Kernel32.dll\GetFileSizeEx", "UInt", hFil, "Int64", &Buffer), fSz := NumGet(Buffer, 0, "Int64")
loop % (fSz // cSz + !!Mod(fSz, cSz))
{
DllCall("Kernel32.dll\ReadFile", "UInt", hFil, "Ptr", &Buffer, "UInt", cSz, "UInt*", Bytes, "UInt", 0)
CRC32 := DllCall("Ntdll.dll\RtlComputeCrc32", "UInt", CRC32, "UInt", &Buffer, "UInt", Bytes, "UInt")
}
DllCall("Kernel32.dll\CloseHandle", "Ptr", hFil)
SetFormat, Integer, % SubStr((A_FI := A_FormatInteger) "H", 0)
CRC32 := SubStr(CRC32 + 0x1000000000, -7)
DllCall("User32.dll\CharLower", "Str", CRC32)
SetFormat, Integer, %A_FI%
return CRC32, DllCall("Kernel32.dll\FreeLibrary", "Ptr", hMod)
}
;from joedf : fork-fusion of jNizM+Laszlo's functions [to_decimal()+ToBase()]
LC_To_Dec(b, n) { ; 1 < b <= 36, n >= 0
d:=0
StringUpper,n,n
loop % StrLen(n)
{
d *= b, k:=SubStr(n,A_Index,1)
if k is not Integer
k:=Asc(k)-55
d += k
}
return d
}
;from Laszlo : http://www.autohotkey.com/board/topic/15951-base-10-to-base-36-conversion/#entry103624
LC_From_Dec(b,n) { ; 1 < b <= 36, n >= 0
Loop {
d := mod(n,b), n //= b
m := (d < 10 ? d : Chr(d+55)) . m
IfLess n,1, Break
}
Return m
}
LC_Dec2Hex(x) {
return LC_From_Dec(16,x)
}
LC_Hex2Dec(x) {
return LC_To_Dec(16,x)
}
LC_Numvert(num,from,to) { ; from joedf : http://ahkscript.org/boards/viewtopic.php?f=6&t=6363
return LC_From_Dec(to,LC_To_Dec(from,num))
}
;
; Date Updated:
; Friday, November 23rd, 2012 - Tuesday, February 10th, 2015
;
; Script Function:
; Function Library to Encrypt / Decrypt in Div2 (by Joe DF)
; Div2 was invented with a friend for fun, back in ~2010.
; The string is "divided" in 2 during encryption. It is a
; simple reordering of the characters in a string. The was
; to have a human-readable/decryptable message.
;
; Notes:
; AutoTrim should turned off, for the encryption to work properly
; because, in Div2, <spaces> and <New lines> count as a character.
;
LC_Div2_encode(input, WithAutoTrim:=1, numproc:=1) {
if (WithAutoTrim)
StringReplace,input,input,%A_Space%,_,A
loop, %numproc%
{
final:="", inputlen := StrLen(input)
divmax := ceil((0.5 * inputlen) + 1)
loop, %inputlen%
{
temp := SubStr(input,A_Index,1)
q := inputlen + 1 - A_Index
temp2 := SubStr(input,q,1)
if (A_Index < divmax) {
final .= temp
if (A_Index != q)
final .= temp2
}
if (A_Index >= divmax)
Break
}
input := final
}
return final
}
LC_Div2_decode(input, WithAutoTrim:=1, numproc:=1) {
if (WithAutoTrim)
StringReplace,input,input,%A_Space%,_,A
loop, %numproc%
{
i := 1, final:="", inputlen := StrLen(input)
loop, % loopc := ceil(inputlen * (1/2))
{
if (i <= inputlen)
final .= SubStr(input,i,1)
i += 2
}
i := inputlen
loop, %loopc%
{
if (i <= inputlen) {
if (mod(SubStr(i,0,1)+0,2)==1) {
if (i != 1)
final .= SubStr(input,i-1,1)
} else {
final .= SubStr(input,i,1)
}
}
i -= 2
}
input := final
}
return final
}
LC_HMAC(Key, Message, Algo := "MD5") {
static Algorithms := {MD2: {ID: 0x8001, Size: 64}
, MD4: {ID: 0x8002, Size: 64}
, MD5: {ID: 0x8003, Size: 64}
, SHA: {ID: 0x8004, Size: 64}
, SHA256: {ID: 0x800C, Size: 64}
, SHA384: {ID: 0x800D, Size: 128}
, SHA512: {ID: 0x800E, Size: 128}}
static iconst := 0x36
static oconst := 0x5C
if (!(Algorithms.HasKey(Algo)))
{
return ""
}
Hash := KeyHashLen := InnerHashLen := ""
HashLen := 0
AlgID := Algorithms[Algo].ID
BlockSize := Algorithms[Algo].Size
MsgLen := StrPut(Message, "UTF-8") - 1
KeyLen := StrPut(Key, "UTF-8") - 1
VarSetCapacity(K, KeyLen + 1, 0)
StrPut(Key, &K, KeyLen, "UTF-8")
if (KeyLen > BlockSize)
{
LC_CalcAddrHash(&K, KeyLen, AlgID, KeyHash, KeyHashLen)
}
VarSetCapacity(ipad, BlockSize + MsgLen, iconst)
Addr := KeyLen > BlockSize ? &KeyHash : &K
Length := KeyLen > BlockSize ? KeyHashLen : KeyLen
i := 0
while (i < Length)
{
NumPut(NumGet(Addr + 0, i, "UChar") ^ iconst, ipad, i, "UChar")
i++
}
if (MsgLen)
{
StrPut(Message, &ipad + BlockSize, MsgLen, "UTF-8")
}
LC_CalcAddrHash(&ipad, BlockSize + MsgLen, AlgID, InnerHash, InnerHashLen)
VarSetCapacity(opad, BlockSize + InnerHashLen, oconst)
Addr := KeyLen > BlockSize ? &KeyHash : &K
Length := KeyLen > BlockSize ? KeyHashLen : KeyLen
i := 0
while (i < Length)
{
NumPut(NumGet(Addr + 0, i, "UChar") ^ oconst, opad, i, "UChar")
i++
}
Addr := &opad + BlockSize
i := 0
while (i < InnerHashLen)
{
NumPut(NumGet(InnerHash, i, "UChar"), Addr + i, 0, "UChar")
i++
}
return LC_CalcAddrHash(&opad, BlockSize + InnerHashLen, AlgID)
}
LC_MD2(string, encoding = "UTF-8") {
return LC_CalcStringHash(string, 0x8001, encoding)
}
LC_HexMD2(hexstring) {
return LC_CalcHexHash(hexstring, 0x8001)
}
LC_FileMD2(filename) {
return LC_CalcFileHash(filename, 0x8001, 64 * 1024)
}
LC_AddrMD2(addr, length) {
return LC_CalcAddrHash(addr, length, 0x8001)
}
LC_MD4(string, encoding = "UTF-8") {
return LC_CalcStringHash(string, 0x8002, encoding)
}
LC_HexMD4(hexstring) {
return LC_CalcHexHash(hexstring, 0x8002)
}
LC_FileMD4(filename) {
return LC_CalcFileHash(filename, 0x8002, 64 * 1024)
}
LC_AddrMD4(addr, length) {
return LC_CalcAddrHash(addr, length, 0x8002)
}
LC_MD5(string, encoding = "UTF-8") {
return LC_CalcStringHash(string, 0x8003, encoding)
}
LC_HexMD5(hexstring) {
return LC_CalcHexHash(hexstring, 0x8003)
}
LC_FileMD5(filename) {
return LC_CalcFileHash(filename, 0x8003, 64 * 1024)
}
LC_AddrMD5(addr, length) {
return LC_CalcAddrHash(addr, length, 0x8003)
}
;nnnik's custom encryption algorithm
;Version 2.1 of the encryption/decryption functions
LC_nnnik21_encryptStr(str="",pass="")
{
If !(enclen:=(strput(str,"utf-16")*2))
return "Error: Nothing to Encrypt"
If !(passlen:=strput(pass,"utf-8")-1)
return "Error: No Pass"
enclen:=Mod(enclen,4) ? (enclen) : (enclen-2)
Varsetcapacity(encbin,enclen,0)
StrPut(str,&encbin,enclen/2,"utf-16")
Varsetcapacity(passbin,passlen+=mod((4-mod(passlen,4)),4),0)
StrPut(pass,&passbin,strlen(pass),"utf-8")
LC_nnnik21_encryptbin(&encbin,enclen,&passbin,passlen)
LC_Base64_Encode(Text, encbin, enclen)
return Text
}
LC_nnnik21_decryptStr(str="",pass="")
{
If !((strput(str,"utf-16")*2))
return "Error: Nothing to Decrypt"
If !((passlen:=strput(pass,"utf-8")-1))
return "Error: No Pass"
Varsetcapacity(passbin,passlen+=mod((4-mod(passlen,4)),4),0)
StrPut(pass,&passbin,strlen(pass),"utf-8")
enclen:=LC_Base64_Decode(encbin, str)
LC_nnnik21__decryptbin(&encbin,enclen,&passbin,passlen)
return StrGet(&encbin,"utf-16")
}
LC_nnnik21_encryptbin(pBin1,sBin1,pBin2,sBin2)
{
b:=0
Loop % sBin1/4
{
a:=numget(pBin1+0,sBin1-A_Index*4,"uint")
numput(a+b,pBin1+0,sBin1-A_Index*4,"uint")
b:=(a+b)*a
}
Loop % sBin2/4
{
c:=numget(pBin2+0,(A_Index-1)*4,"uint")
b:=0
Loop % sBin1/4
{
a:=numget(pBin1+0,(A_Index-1)*4,"uint")
numput((a+b)^c,pBin1+0,(A_Index-1)*4,"uint")
b:=(a+b)*a
}
}
}
LC_nnnik21__decryptbin(pBin1,sBin1,pBin2,sBin2){
Loop % sBin2/4
{
c:=numget(pBin2+0,sBin2-A_Index*4,"uint")
b:=0
Loop % sBin1/4
{
a:=numget(pBin1+0,(A_Index-1)*4,"uint")
numput(a:=(a^c)-b,pBin1+0,(A_Index-1)*4,"uint")
b:=(a+b)*a
}
}
b:=0
Loop % sBin1/4
{
a:=numget(pBin1+0,sBin1-A_Index*4,"uint")
numput(a:=a-b,pBin1+0,sBin1-A_Index*4,"uint")
b:=(a+b)*a
}
}
LC_RC4_Encrypt(Data,Pass) {
Format:=A_FormatInteger,b:=0,j:=0,Key:=Object(),sBox:=Object()
SetFormat,Integer,Hex
VarSetCapacity(Result,StrLen(Data)*2)
Loop 256
a:=(A_Index-1),Key[a]:=Asc(SubStr(Pass,Mod(a,StrLen(Pass))+1,1)),sBox[a]:=a
Loop 256
a:=(A_Index-1),b:=(b+sBox[a]+Key[a])&255,sBox[a]:=(sBox[b]+0,sBox[b]:=sBox[a]) ; SWAP(a,b)
Loop Parse, Data
i:=(A_Index&255),j:=(sBox[i]+j)&255,k:=(sBox[i]+sBox[j])&255,sBox[i]:=(sBox[j]+0,sBox[j]:=sBox[i]) ; SWAP(i,j)
,Result.=SubStr(Asc(A_LoopField)^sBox[k],-1,2)
StringReplace,Result,Result,x,0,All
SetFormat,Integer,%Format%
Return Result
}
LC_RC4_Decrypt(Data,Pass) {
b:=0,j:=0,x:="0x",Key:=Object(),sBox:=Object()
VarSetCapacity(Result,StrLen(Data)//2)
Loop 256
a:=(A_Index-1),Key[a]:=Asc(SubStr(Pass,Mod(a,StrLen(Pass))+1,1)),sBox[a]:=a
Loop 256
a:=(A_Index-1),b:=(b+sBox[a]+Key[a])&255,sBox[a]:=(sBox[b]+0,sBox[b]:=sBox[a]) ; SWAP(a,b)
Loop % StrLen(Data)//2
i:=(A_Index&255),j:=(sBox[i]+j)&255,k:=(sBox[i]+sBox[j])&255,sBox[i]:=(sBox[j]+0,sBox[j]:=sBox[i]) ; SWAP(i,j)
,Result.=Chr((x . SubStr(Data,(2*A_Index)-1,2))^sBox[k])
Return Result
}
LC_RC4(RC4Data,RC4Pass) { ; Thanks Rajat for original, Updated Libcrypt version
; http://www.autohotkey.com/board/topic/570-rc4-encryption/page-2#entry25712
ATrim:=A_AutoTrim,BLines:=A_BatchLines,RC4PassLen:=StrLen(RC4Pass),Key:=Object(),sBox:=Object(),b:=0,RC4Result:="",i:=0,j:=0
AutoTrim,Off
SetBatchlines,-1
Loop, 256
a:=(A_Index-1),ModVal:=Mod(a,RC4PassLen),c:=SubStr(RC4Pass,ModVal+=1,1),Key[a]:=Asc(c),sBox[a]:=a
Loop, 256
a:=(A_Index-1),b:=Mod(b+sBox[a]+Key[a],256),T:=sBox[a],sBox[a]:=sBox[b],sBox[b]:=T
Loop, Parse, RC4Data
i:=Mod(i+1,256),j:=Mod(sBox[i]+j,256),k:=sBox[Mod(sBox[i]+sBox[j],256)],c:=Asc(A_LoopField)^k,c:=((c==0)?k:c),RC4Result.=Chr(c)
AutoTrim, %ATrim%
SetBatchlines, %BLines%
Return RC4Result
}
/*
- ROT5 covers the numbers 0-9.
- ROT13 covers the 26 upper and lower case letters of the Latin alphabet (A-Z, a-z).
- ROT18 is a combination of ROT5 and ROT13.
- ROT47 covers all printable ASCII characters, except empty spaces. Besides numbers and the letters of the Latin alphabet,
the following characters are included:
!"#$%&'()*+,-./:;<=>?[\]^_`{|}~
*/
LC_Rot5(string) {
Loop, Parse, string
s .= (strlen((c:=A_LoopField)+0)?((c<5)?c+5:c-5):(c))
Return s
}
; by Raccoon July-2009
; http://rosettacode.org/wiki/Rot-13#AutoHotkey
LC_Rot13(string) {
Loop, Parse, string
{
c := asc(A_LoopField)
if (c >= 97) && (c <= 109) || (c >= 65) && (c <= 77)
c += 13
else if (c >= 110) && (c <= 122) || (c >= 78) && (c <= 90)
c -= 13
s .= Chr(c)
}
Return s
}
LC_Rot18(string) {
return LC_Rot13(LC_Rot5(string))
}
; adapted from http://langref.org/fantom+java+scala/strings/reversing-a-string/simple-substitution-cipher
; from decimal 33 '!' through 126 '~', 94
LC_Rot47(string) {
Loop Parse, string
{
c := Asc(A_LoopField)
c += (c >= Asc("!") && c <= Asc("O") ? 47 : (c >= Asc("P") && c <= Asc("~") ? -47 : 0))
s .= Chr(c)
}
Return s
}
; RSHash (Robert Sedgewick's string hashing algorithm)
; from jNizM
; https://autohotkey.com/boards/viewtopic.php?p=87929#p87929
LC_RSHash(str) {
a := 0xF8C9, b := 0x5C6B7, h := 0
loop, parse, str
h := h * a + Asc(A_LoopField), a *= b
return (h & 0x7FFFFFFF)
}
LC_SecureSalted(salt, message, algo := "md5") {
hash := ""
saltedHash := %algo%(message . salt)
saltedHashR := %algo%(salt . message)
len := StrLen(saltedHash)
loop % len / 2
{
byte1 := "0x" . SubStr(saltedHash, 2 * A_index - 1, 2)
byte2 := "0x" . SubStr(saltedHashR, 2 * A_index - 1, 2)
SetFormat, integer, hex
hash .= StrLen(ns := SubStr(byte1 ^ byte2, 3)) < 2 ? "0" ns : ns
}
SetFormat, integer, dez
return hash
}
LC_SHA(string, encoding = "UTF-8") {
return LC_CalcStringHash(string, 0x8004, encoding)
}
LC_HexSHA(hexstring) {
return LC_CalcHexHash(hexstring, 0x8004)
}
LC_FileSHA(filename) {
return LC_CalcFileHash(filename, 0x8004, 64 * 1024)
}
LC_AddrSHA(addr, length) {
return LC_CalcAddrHash(addr, length, 0x8004)
}
LC_SHA256(string, encoding = "UTF-8") {
return LC_CalcStringHash(string, 0x800c, encoding)
}
LC_HexSHA256(hexstring) {
return LC_CalcHexHash(hexstring, 0x800c)
}
LC_FileSHA256(filename) {
return LC_CalcFileHash(filename, 0x800c, 64 * 1024)
}
LC_AddrSHA256(addr, length) {
return LC_CalcAddrHash(addr, length, 0x800c)
}
LC_SHA384(string, encoding = "UTF-8") {
return LC_CalcStringHash(string, 0x800d, encoding)
}
LC_HexSHA384(hexstring) {
return LC_CalcHexHash(hexstring, 0x800d)
}
LC_FileSHA384(filename) {
return LC_CalcFileHash(filename, 0x800d, 64 * 1024)
}
LC_AddrSHA384(addr, length) {
return LC_CalcAddrHash(addr, length, 0x800d)
}
LC_SHA512(string, encoding = "UTF-8") {
return LC_CalcStringHash(string, 0x800e, encoding)
}
LC_HexSHA512(hexstring) {
return LC_CalcHexHash(hexstring, 0x800e)
}
LC_FileSHA512(filename) {
return LC_CalcFileHash(filename, 0x800e, 64 * 1024)
}
LC_AddrSHA512(addr, length) {
return LC_CalcAddrHash(addr, length, 0x800e)
}
; Modified by GeekDude from http://goo.gl/0a0iJq
LC_UriEncode(Uri, RE="[0-9A-Za-z]") {
VarSetCapacity(Var, StrPut(Uri, "UTF-8"), 0), StrPut(Uri, &Var, "UTF-8")
While Code := NumGet(Var, A_Index - 1, "UChar")
Res .= (Chr:=Chr(Code)) ~= RE ? Chr : Format("%{:02X}", Code)
Return, Res
}
LC_UriDecode(Uri) {
Pos := 1
While Pos := RegExMatch(Uri, "i)(%[\da-f]{2})+", Code, Pos)
{
VarSetCapacity(Var, StrLen(Code) // 3, 0), Code := SubStr(Code,2)
Loop, Parse, Code, `%
NumPut("0x" A_LoopField, Var, A_Index-1, "UChar")
Decoded := StrGet(&Var, "UTF-8")
Uri := SubStr(Uri, 1, Pos-1) . Decoded . SubStr(Uri, Pos+StrLen(Code)+1)
Pos += StrLen(Decoded)+1
}
Return, Uri
}
;----------------------------------
LC_UrlEncode(Url) { ; keep ":/;?@,&=+$#."
return LC_UriEncode(Url, "[0-9a-zA-Z:/;?@,&=+$#.]")
}
LC_UrlDecode(url) {
return LC_UriDecode(url)
}
;
; Version: 2014.03.06-1518, jNizM
; see https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
; ===================================================================================
LC_VigenereCipher(string, key, enc := 1) {
enc := "", DllCall("user32.dll\CharUpper", "Ptr", &string, "Ptr")
, string := RegExReplace(StrGet(&string), "[^A-Z]")
loop, parse, string
{
a := Asc(A_LoopField) - 65
, b := Asc(SubStr(key, 1 + Mod(A_Index - 1, StrLen(key)), 1)) - 65
, enc .= Chr(Mod(a + b, 26) + 65)
}
return enc
}
LC_VigenereDecipher(string, key) {
dec := ""
loop, parse, key
dec .= Chr(26 - (Asc(A_LoopField) - 65) + 65)
return LC_VigenereCipher(string, dec)
}
; FUnctions and algorithm by VxE
; intergrated into libcrypt.ahk with "LC_" prefixes
/*
####################################################################################################
####################################################################################################
###### ######
###### [VxE]-251 Encryption ######
###### & ######
###### [VxE]-89 Encryption ######
###### ######
####################################################################################################
####################################################################################################
[VxE] 251 encryption is a rotation-based encryption algorithm using a dynamic key and a
dynamic map. The '251' indicates the size of the map, which omits the following byte-values:
0x00 ( null byte: string terminator )
0x09 ( tab character: common text formatting character )
0x0A ( newline character: common text formatting character )
0x0D ( carriage return character: common text formatting character )
0x7F ( wierd character: ascii 'del' )
This encryption function also supports an 89-character map, which incorporates the byte values
between 0x20 and 0x7e, omitting 0x22, 0x27, 0x2C, 0x2F, 0x5C, and 0x60. This mode allows text value
input to be encrypted as text without high-ascii characters or non-printable characters.
*/
; ##################################################################################################
; ## Function shortcuts
LC_VxE_Encrypt89( key, byref message ) { ; ----------------------------------------------------------
Return LC_VxE_Crypt( key, message, 1, "vxe89 len" StrLen( message ) << !!A_IsUnicode )
} ; VxE_Encrypt89( key, byref message ) ----------------------------------------------------------
LC_VxE_Decrypt89( key, byref message ) { ; ----------------------------------------------------------
Return LC_VxE_Crypt( key, message, 0, "vxe89 len" StrLen( message ) << !!A_IsUnicode )
} ; VxE_Decrypt89( key, byref message ) ----------------------------------------------------------
LC_VxE_Encrypt251( key, byref message, len ) { ; ----------------------------------------------------
Return LC_VxE_Crypt( key, message, 1, "len" len )
} ; VxE_Encrypt251( key, byref message, len ) ----------------------------------------------------
LC_VxE_Decrypt251( key, byref message, len ) { ; ----------------------------------------------------
Return LC_VxE_Crypt( key, message, 0, "len" len )
} ; VxE_Decrypt251( key, byref message, len ) ----------------------------------------------------
; ##################################################################################################
; ## The core function
LC_VxE_Crypt( key, byref message, direction = 1, options="" ) { ; -----------------------------------
; Transorms the message. 'direction' indicates whether or not to decrypt or encrypt the message.
; However, since this algorithm is symmetrical, distinguishing between 'encrypt' and 'decrypt' is
; merely for the benefit of human understanding.
; This agorithm was developed by [VxE] in July 2010. When a key/message are passed to this function,
; it generates the rotation map using the key. Then, it traverses the bytes in the message, rotating
; their values along the map according to the key. Once the character's encoded value is determined,
; the key is augmented by a value based on the byte value.
If !RegexMatch( options, "i)(?:len|l)\K(?:0x[\da-fA-F]+|\d+)", length ) ; check explicit length
length := StrLen( message ) << !!A_IsUnicode ; otherwise, find length.
UseVxE89 := InStr( options, "vxe89" ) ; check 'options' for text-friendly mode.
direction := 2 * ( direction = 1 ) - 1 ; coerce the 'direction' to either +1 or -1.
w := StrLen( key ) << !!A_IsUnicode
; 'w' holds the derived key, which is a 32-bit integer based on the key.
; Although this doesn't seem very entropic, remember that the map is also derived from the key.
If (UseVxE89) ; using the smaller map allows text-friendly encrypting since the small map is
Loop 126 ; composed only of low-ascii printable characters
If ( A_Index >= 32 && A_Index != 34 && A_Index != 39 && A_Index != 44
&& A_Index != 47 && A_Index != 92 && A_Index != 96 )
map .= Chr( A_Index )
If !UseVxE89 ; the 251 map is more suitable for non-text data
Loop 255
If ( A_Index != 9 && A_Index != 10 && A_Index != 13 && A_Index != 127 )
map .= Chr( A_Index )
k := StrLen( map ) ; keep the length of the map
Loop 9 ; pad the key up to 509 characters, mixing in digit-characters
If StrLen( key ) < 509
key := SubStr( key Chr( 48 + A_Index ) key, 1, 509 )
Loop 509 ; rearrange the map, using the padded key as the selector.
{ ; This is how the map becomes dynamic. 509 times, a char is selected from the map and
; is extracted from the map string, then appended to it. At the same time, the derived key is
; augmented by XORing it with a value based on each byte in the key.
q := *( &key + A_Index - 1 )
pos := 1 + Mod( q * A_Index * 3, k )
StringMid, e, map, %pos%, 1
StringLeft, i, map, pos - 1
StringTrimLeft, c, map, %pos%
map := i c e
w ^= q * A_Index * 1657
}
x := 0
Loop %length%
{
c := NumGet( message, A_Index - 1, "UChar" ) ; for each byte in the message
If !c || !( i := InStr( map, Chr( c ), 1 ) )
Continue ; if the character isn't in the map, just skip it.
i-- ; the map index should be zero based for easier use with Mod() function
x++ ; this tracks the actual index, not the char position.
e := Mod( 223390000 + i + w * direction, k ) ; rotate the index along the map
c := Asc( SubStr( map, e + 1, 1 ) ) ; lookup the character at the rotated index
NumPut( c, message, A_Index - 1, "UChar" ) ; append the newly-mapped char to the result
; Finally, depending on the direction of rotation, use either the original index or
; the rotated index to augment the derived key
If ( direction = 1 )
c := Mod( e + x, 251 )
Else c := Mod( i + x, 251 )
w ^= c | c << 8 | c << 16 | c << 24
}
return length
} ; VxE_Crypt( key, byref message, direction = 1, options="" ) -----------------------------------
LC_XOR_Encrypt(str,key) {
EncLen:=StrPut(Str,"UTF-16")*2
VarSetCapacity(EncData,EncLen)
StrPut(Str,&EncData,"UTF-16")
PassLen:=StrPut(key,"UTF-8")
VarSetCapacity(PassData,PassLen)
StrPut(key,&PassData,"UTF-8")
LC_XOR(OutData,EncData,EncLen,PassData,PassLen)
LC_Base64_Encode(OutBase64, OutData, EncLen)
return OutBase64
}
LC_XOR_Decrypt(OutBase64,key) {
EncLen:=LC_Base64_Decode(OutData, OutBase64)
PassLen:=StrPut(key,"UTF-8")
VarSetCapacity(PassData,PassLen)
StrPut(key,&PassData,"UTF-8")
LC_XOR(EncData,OutData,EncLen,PassData,PassLen)
return StrGet(&EncData,"UTF-16")
}
LC_XOR(byref OutData,byref EncData,EncLen,byref PassData,PassLen)
{
VarSetCapacity(OutData,EncLen)
Loop % EncLen
NumPut(NumGet(EncData,A_Index-1,"UChar")^NumGet(PassData,Mod(A_Index-1,PassLen),"UChar"),OutData,A_Index-1,"UChar")
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+28
View File
@@ -0,0 +1,28 @@
#Requires AutoHotkey v2.0
#Include libcrypt_v2.ahk2
passed := 0, failed := 0, report := ""
Test(name, actual, expected) {
global passed, failed, report
if actual = expected
passed++, report .= "PASS " name "`n"
else
failed++, report .= "FAIL " name "`n expected: " expected "`n actual: " actual "`n"
}
text := "Hello, Welt! 123 äöü"
Test("ASCII2Bin", LC_Bin2Ascii(LC_ASCII2Bin("ABC")), "ABC")
Test("BinStr UTF-8", LC_BinStr_DecodeText(LC_BinStr_EncodeText(text)), text)
Test("Base64 UTF-8", LC_Base64_DecodeText(LC_Base64_EncodeText(text)), text)
Test("ASCII85 original", LC_ASCII85_Decode(LC_ASCII85_Encode("Hello")), "Hello")
Test("ASCII85 Z85", LC_ASCII85_Decode(LC_ASCII85_Encode("test", "z"), "z"), "test")
Test("Caesar", LC_Caesar("Abc XyZ", 2), "Cde ZaB")
Test("ROT5", LC_Rot5("a1239"), "a6784")
Test("ROT13", LC_Rot13("Hello"), "Uryyb")
Test("ROT18", LC_Rot18("Hello 123"), "Uryyb 678")
Test("ROT47", LC_Rot47(LC_Rot47("Hello! 123")), "Hello! 123")
Test("URI", LC_UriDecode(LC_UriEncode("ä & x")), "ä & x")
Test("URL", LC_UrlDecode(LC_UrlEncode("https://example.com/a?x=ä")), "https://example.com/a?x=ä")
Test("Div2", LC_Div2_decode(LC_Div2_encode("abcdef", false), false), "abcdef")
MsgBox("Passed: " passed "`nFailed: " failed "`n`n" report, "libcrypt v2 tests")
ExitApp()
+22
View File
@@ -0,0 +1,22 @@
#Requires AutoHotkey v2
;#Include .\libcrypt.ahk
message := "The quick brown fox jumps over the lazy dog"
salt := "key"
LC_Bin2Ascii(Bin) {
Bin := RegExReplace(Bin, "[^10]")
Loop StrLen(Bin) / 8 {
Asc := 0
for Bit in StrSplit(SubStr(Bin, (A_Index - 1) * 8 + 1, 8))
Asc += Asc + Bit
Out .= Chr(Asc)
}
return Out
}
tst := LC_Bin2Ascii("01100110")
MsgBox(tst)
;MsgBox("SHA256:`t`t" LC_SHA256(message) "`nSHA256 + Salt:`t" LC_SecureSalted(salt, message, "sha256") "`n`n")