ahkscript / libcrypt.ahk Goto Github PK
View Code? Open in Web Editor NEWA collection of crypting and encoding functions from the community
License: MIT License
A collection of crypting and encoding functions from the community
License: MIT License
Same for Laszlo Fast 64- and 128-bit hash function
http://www.autohotkey.com/board/topic/14040-fast-64-and-128-bit-hash-functions/
They are nothing else than an enhanced Version of stringxoring.
And also can I include the Base64 function?
LC_VigenereCipher("Testingabc","Lemon") gives a result of "EOKNBYQSVV" which is supposed to be "Eiehvykmpp" and using LC_VigenereDecipher(LC_VigenereCipher("Testingabc","Lemon"),"Lemon") gives a result of "TE9:/NGABC" which is supposed to be "Testingabc" in the ideal scenario, but since there is an error somewhere in the encrypting process, the output should be "TKYZONMGHI" when the Input to the decipher function is "EOKNBYQSVV".
https://ciphereditor.com/ to verify
I'm planning on adding some Encryption/Decryption to my Lintalist program as a plugin but I'm not sure which encryption to use. I have a working example with RC4 and nnnik21 by @nnnik - but there is also AES by @jNizM which may not be fully ready yet(?):
RC4 isn't very secure as far as I know so I'll scratch that one.
Changing the encryption used at a later stage could be annoying as the user would have to run a conversion script to go from one encryption to the new one so I'd rather pick one and stick with it.
Currently, it is built with make.ahk. should be have an installer, be a pacakge or be a template?
This is the follow-up conversation started here : #13
Should this repo become a collection of individual functions and libraries OR should all crypting functions be included into one bigger stdlib compatible library?
Base64.ahk
Rot13.ahk
etc
vs
LC_Base64_*
LC_Rot13
etc
ASCII85 is almost fully working...
In the example/ folder, the script fails to decode correctly for the ~2 last characters.
https://github.com/ahkscript/libcrypt.ahk/blob/master/examples/ASCII85.ahk
Anyone know where I can find an RC4 algo using the WinCryptoApi? I'm currently using Laszlo's which looks similar to the one in this repo. But both are dependent upon SetFormat which is removed in AHK v2. So I'm hoping for a quick link to an algo using the win api but still encrypts to hex...
Currently, the nnnik21 encryption does not have an example script.
As I see you add custom Encryption like nnnik's one, ask VxE to add this function
http://www.autohotkey.com/board/topic/56223-vxes-encryption-second-gen/
@nnnik Your version seems to be more efficient but, the decryption is now broken .... :(
Please try out the example : https://github.com/ahkscript/libcrypt.ahk/blob/master/examples/XOR.ahk
Perhaps it would be useful to split the functions1 in the readme into:
TEA
http://www.autohotkey.com/board/topic/4164-editorchat-encryption/
http://www.autohotkey.com/board/topic/4147-small-and-fast-text-file-encryptor/
RC4?
http://www.autohotkey.com/board/topic/6316-rc4-encryption-to-hex-stream/
related:
http://www.autohotkey.com/board/topic/570-rc4-encryption/page-2#entry25712
above seems to be function version of:
http://www.angelfire.com/ultra2/rajat/scripts/rc4.ahk.txt
specifically these
; Modified by GeekDude from http://goo.gl/0a0iJq
UriEncode(Uri)
{
VarSetCapacity(Var, StrPut(Uri, "UTF-8"), 0), StrPut(Uri, &Var, "UTF-8")
f := A_FormatInteger
SetFormat, IntegerFast, H
While Code := NumGet(Var, A_Index - 1, "UChar")
If (Code >= 0x30 && Code <= 0x39 ; 0-9
|| Code >= 0x41 && Code <= 0x5A ; A-Z
|| Code >= 0x61 && Code <= 0x7A) ; a-z
Res .= Chr(Code)
Else
Res .= "%" . SubStr(Code + 0x100, -1)
SetFormat, IntegerFast, %f%
Return, Res
}
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")
StringReplace, Uri, Uri, `%%Code%, % StrGet(&Var, "UTF-8"), All
}
Return, Uri
}
The indentation might be a little bit funny, but that's because of AHK Studio's Auto-Indent not picking up on multiline if statements.
Would anybody mind if I made a script "install.ahk" in the root that automatically copied the latest build to %A_WorkingDir%\AutoHotkey\lib
? And if I do make an installer, should it automatically run make before copying?
There used to be a small Blowfish script on ahk . com which used a DLL which is now hard to find but there are now implementations in JS http://dren.ch/js_blowfish/ and also in AutoIt http://www.autoitscript.com/forum/topic/44581-crypto-suite/?p=332160#entry332160 - doesn't look that complicated to translate to ahk but it gives me headaches so I won't try
I'm currently working on one method to do it. I noticed that all other major cryptography functions were there but not this. That's all I have to say. P.S. Decoding is much harder than encoding.
I'm not sure what that seemingly complicated RegEx filled function is for. Can someone explain?
Deo has a few algos in his class which may be borrowed
http://www.autohotkey.com/board/topic/67155-ahk-l-crypt-ahk-cryptography-class-encryption-hashing/
Hashing (Custom): RSHash
see: https://autohotkey.com/boards/viewtopic.php?p=87929#p87929
Not a big deal, just differs from the standard (in my case caused a little conflict). RegEx parameter should be [!#$&-;=?-Z_a-z~]
in
Line 26 in 2558ea6
Rationale:
In ascii-code.com a more visual representation is found, however getting a list of all the non-control ASCII chars:
i := 33, s :=
While (i < 127)
s .= Chr(i++)
/* Result:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
*/
And in a JavaScript console:
// Escaped: Single quote and Backslash
uri = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
enc = encodeURI(uri);
dec = decodeURI(enc);
console.log(enc)
console.log(dec)
Removing the encoded chars leaves the list provided as RegEx. Hope it helps someone.
The function usage should have a standard format of documentation as a short comment over each function in its lib file.
Suggested format:
Description : [tab] ...
Usage : [tab] param1 - the input string to be ...
[tab] [tab?] param2 - ...
Thoughts?
==>
For example, LC_UriDecode("%2534")
returns 4
instead of %34
. I've written a version of the function that doesn't have that problem, but it's roughly 2x slower by my benchmarks.
UriDecode(Uri)
{
VarSetCapacity(Out, StrLen(Uri)+1, 0), Ptr := &Out, i := 1
While Char := SubStr(Uri, i++, 1)
NumPut(Char=="%"?"0x" SubStr(Uri,-2+i+=2,2):Asc(Char),Ptr++,"UChar")
Return, StrGet(&Out, "UTF-8")
}
derRaphael posted rotx (rot5, 13 and 47) here http://www.autohotkey.com/board/topic/57125-rotx-feat-rot5-rot13-and-rot47/
But for me only 5 & 13 work - the 47 fails with lowercase input so it transforms the H from Hello but leaves ello intact - or is just me?
String is: Hello World #123
ROT13 returns: Uryyb Jbeyq #123
ROT47 should return: w6==@ (@C=5 R`ab
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.