I have a 12 digit number: 133565828659
I want to encrypt this (and after decrypt).
What are my options?
I spent 20-30 minutes going through different options I found on Google.
One promising one from this link: https://github.com/aviaryan/autohotkey-scripts/blob/master/Functions/Encrypt.ahk
But this requires another file the guy wrote - this, I can't find.
IMPORTANT: I want the output to be the same length or shorter than the input.
Doesn't matter if we use characters - the end output doesn't have to be numbers.
Thanks.
How to encrypt
Re: How to encrypt
Looks great
I can't figure out how to use though
I've looked at the examples and it's not making sense!
For example:
MsgBox % Crypt.Hash.String("SHA1", "The quick brown fox jumps over the lazy dog")
; -> 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
How would one decrypt?
Then you have:
MsgBox % Crypt.Encrypt.String("AES", "CBC", "abcdefghijklmnop", "1234567890123456", "1234567890123456")
; -> Nn9CFFuC+/O84cV1NiwLYoyd25Z9nmWv16dIFKzf2b4=
and
MsgBox % Crypt.Decrypt.String("AES", "CBC", "Nn9CFFuC+/O84cV1NiwLYoyd25Z9nmWv16dIFKzf2b4=", "1234567890123456", "1234567890123456")
; -> abcdefghijklmnop
So that one, I get, I guess
But... I really needed something with a smaller output (or even 2 digits more would be OK).
Any chars are OK - but not + and / chars
Any ideas?
I see the code uses Microsoft dll's. What if someone doesn't have? Just wondering.
Thanks.
I can't figure out how to use though
I've looked at the examples and it's not making sense!
For example:
MsgBox % Crypt.Hash.String("SHA1", "The quick brown fox jumps over the lazy dog")
; -> 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
How would one decrypt?
Then you have:
MsgBox % Crypt.Encrypt.String("AES", "CBC", "abcdefghijklmnop", "1234567890123456", "1234567890123456")
; -> Nn9CFFuC+/O84cV1NiwLYoyd25Z9nmWv16dIFKzf2b4=
and
MsgBox % Crypt.Decrypt.String("AES", "CBC", "Nn9CFFuC+/O84cV1NiwLYoyd25Z9nmWv16dIFKzf2b4=", "1234567890123456", "1234567890123456")
; -> abcdefghijklmnop
So that one, I get, I guess
But... I really needed something with a smaller output (or even 2 digits more would be OK).
Any chars are OK - but not + and / chars
Any ideas?
I see the code uses Microsoft dll's. What if someone doesn't have? Just wondering.
Thanks.
Re: How to encrypt
1) Crypt.Hash.String()
Hashing (e.g. MD5 / SHA1 / SHA2) are one-way functions. You cannot decrypt them (only with brut-force or rainbow tables)
2) Crypt.Eecrypt.String()
You can use the "hexraw" parameter to get just letters and numbers (0-9 + A-F)
(e.g. MsgBox % Crypt.Encrypt.String("AES", "ECB", "133565828659", "1234567890123456",,, "HEXRAW"))
3) if you want some short stuff you can search the forum. there are a few custom enctyptions
Hashing (e.g. MD5 / SHA1 / SHA2) are one-way functions. You cannot decrypt them (only with brut-force or rainbow tables)
2) Crypt.Eecrypt.String()
You can use the "hexraw" parameter to get just letters and numbers (0-9 + A-F)
(e.g. MsgBox % Crypt.Encrypt.String("AES", "ECB", "133565828659", "1234567890123456",,, "HEXRAW"))
3) if you want some short stuff you can search the forum. there are a few custom enctyptions
Re: How to encrypt
Hallo,
try:
try:
Code: Select all
Number := 133565828659
Pass := 123456789012
MsgBox,% Encrypt := Number^Pass
MsgBox,% Decrypt := Encrypt^Pass
Re: How to encrypt
Thanks for the replies guys.
@Rohwedder wow
That looks pretty good. Just what I wanted!
Can you explain what's happening?
How does it work?
Is it this that's doing the work: ^ ?
I can't seem to search for it!
I'll use this.
But would love to know how and why it works!
EDIT: it doesn't work if the number starts with a 0.
So, if I have 0099823924, I need to get out the same, with the leading 0's.
I guess I could hack it by counting the number of digits and adding 0's at the beginning.
But that wouldn't seem right.
Any thoughts?
(Also, wondering if the pass has a zero at the beginning, does it matter?)
Thanks.
@Rohwedder wow
That looks pretty good. Just what I wanted!
Can you explain what's happening?
How does it work?
Is it this that's doing the work: ^ ?
I can't seem to search for it!
I'll use this.
But would love to know how and why it works!
EDIT: it doesn't work if the number starts with a 0.
So, if I have 0099823924, I need to get out the same, with the leading 0's.
I guess I could hack it by counting the number of digits and adding 0's at the beginning.
But that wouldn't seem right.
Any thoughts?
(Also, wondering if the pass has a zero at the beginning, does it matter?)
Thanks.
Re: How to encrypt
See https://www.autohotkey.com/docs/Variables.htm#operators
^ is bitwise-exclusive-or
These two functions should be more "robust":
To keep the string lengths the length of Pass is adjusted.
^ is bitwise-exclusive-or
These two functions should be more "robust":
Code: Select all
Global Pass := 12345678901234567
Number := 00133565828659
MsgBox,% Encrypt := Encrypt(Number)
MsgBox,% Decrypt := Decrypt(Encrypt)
Return
Encrypt(No)
{
Pass2 := SubStr(Pass, 1, Len:=StrLen(No)-1)
Return, SubStr(Format("{:049X}", No^Pass2), -Len)
}
Decrypt(No)
{
Pass2 := SubStr(Pass, 1, Len:=StrLen(No)-1)
No := "0X" No
Return, SubStr(Format("{:049u}", No^Pass2), -Len)
}