AESENCRYPT help

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
tbrackett
Newbie
Posts: 11
Joined: Wed Dec 07, 2005 5:00 pm

AESENCRYPT help

Post by tbrackett » Mon Jul 02, 2018 4:36 pm

Hi Marcus and everyone!
I am going a little crazy trying to match the encryption of aesencrypt...
I would like to use a web function that will follow the same encryption method so that MS can exchange encrypted text with it.
Using an online site to try to match up the function:

https://www.devglan.com/online-tools/ae ... decryption

As I understand, AESencrypt is taking the passkey entered, and applying SHA256 to it - but this creates a 64 byte string for the key. AES256 needs a 32 byte string?!?!

E.g: passkey of "hello world" becomes
B94D27B9934D3E08A52E52D7DA7DABFAC484EFE37A5380EE9088F7ACE2EFCDE9

Are you really using AES512 to accomodate a 64 byte key?

tbrackett
Newbie
Posts: 11
Joined: Wed Dec 07, 2005 5:00 pm

Re: AESENCRYPT help

Post by tbrackett » Mon Jul 02, 2018 7:34 pm

or are you substringing the sha256 to grab 32 byte string? Or double substringing yo get the additional IV string? ;)

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: AESENCRYPT help

Post by Marcus Tettmar » Tue Jul 03, 2018 12:55 pm

Hi Tony,

I'm looking into this right now for you.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: AESENCRYPT help

Post by Marcus Tettmar » Tue Jul 03, 2018 2:39 pm

I wonder if the size difference we are seeing here is because of Unicode. Macro Scheduler is using Unicode. Perhaps we need a way to specify the character encoding.

However, I've now tried three different online AES128 SHA256 CBC encryption/decryption tools and they all give different answers, so .... ;-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

tbrackett
Newbie
Posts: 11
Joined: Wed Dec 07, 2005 5:00 pm

Re: AESENCRYPT help

Post by tbrackett » Fri Jul 06, 2018 3:53 pm

Thanks Marcus!
I will research unicode encryption.
At least I can focus on AES128.
But can you confirm you are passing all 64 characters of the sha256? Maybe that means utf32 is the unicode set? 4x of utf8 and 64 chars of sha256 is 4x of the 16 charts required for key of AES128....
Ow... brain.... hurts...

tbrackett
Newbie
Posts: 11
Joined: Wed Dec 07, 2005 5:00 pm

Re: AESENCRYPT help

Post by tbrackett » Fri Jul 06, 2018 4:59 pm

Hmmmmmm. reading more AES128 can only have 128bits in the key even if source text is unicode?
so how can sha 256bit be used as the key?

tbrackett
Newbie
Posts: 11
Joined: Wed Dec 07, 2005 5:00 pm

Re: AESENCRYPT help

Post by tbrackett » Fri Jul 06, 2018 8:18 pm

Oh wait Alex - I just reread your message -
You said you are using AES128 CBC - does that mean you are using an IV (initialization vector)?
Like you use 16 bytes of a substring of the SHA256 for the key, and another 16 byte substring for the IV?
Anything you can help me to understand what pieceof the SHA256 64 byte string you use would be awesome - Then I can use Hash> with SHA256 and substring/length to get the correct ascii key... I saw how C and Delphi will length the SHA256 to derive a key
(https://stackoverflow.com/questions/918 ... crypt-in-c)
so I would assume you are doing the same?

I was able to get two sites to match CBC output:

SOURCE TEXT:
Now is the time to encryptWe will use AES encryption now!I change function to better standard which is SHA256 hashed encryptionThen I am using BASE64 to make the binary encryption into unicode text.Now is the time to encryptWe will use AES encryption now!
KEY:
1234567890123456


https://www.devglan.com/online-tools/ae ... decryption
AES128 - CBC - (no IV option)
RESULT:
7MeJD7kGc9XbfBDC0U3k3JHvtmerPswKmR5WiUMPHrMZ1TwnOsFEOtLO93KamkH/bYCmWn0GeHJ9FEPdv/xvAGit4NHV7cZ6t//xi3xdpcpssyYNid1EMdM154ULi5R1pNs/yslDKN8iQjjuEgL75NOV7i4jd7eTcPd9bi1S8mncatATrodHtSPOSeXTJYwLJVuaENEuHon0BPGyYZLoT7ftV6zB3Q1oexsTrUpSqectZdB/Iy5bVqNzaX3OA2e41xY0lJ2VOLke4UrUXTk0G+pAd5UcrrvoiAyye0BrZfNVMj4n3S92wEiI3lZtyWUr4WlufKAeCyfNbRZYcQeHLw==

https://encode-decode.com/aes128-encrypt-online/
AES128 (assume background is CBC no IV)
7MeJD7kGc9XbfBDC0U3k3JHvtmerPswKmR5WiUMPHrMZ1TwnOsFEOtLO93KamkH/bYCmWn0GeHJ9FEPdv/xvAGit4NHV7cZ6t//xi3xdpcpssyYNid1EMdM154ULi5R1pNs/yslDKN8iQjjuEgL75NOV7i4jd7eTcPd9bi1S8mncatATrodHtSPOSeXTJYwLJVuaENEuHon0BPGyYZLoT7ftV6zB3Q1oexsTrUpSqectZdB/Iy5bVqNzaX3OA2e41xY0lJ2VOLke4UrUXTk0G+pAd5UcrrvoiAyye0BrZfNVMj4n3S92wEiI3lZtyWUr4WlufKAeCyfNbRZYcQeHLw==

MSCHED AESEncrypt output (after Base64) using same key in password:
QnbYykYOINF8I06XpTwo76a+DNOuOX4dPmCJBW3UsTa/P1bhAvyHQLYfb2Mp2sSrjPco9MBfWkURJXuX6Q3t+hULmQmTkxRWVg/YR73XgVEfuMKvfMwFvDbyQdHroifpa42fgEZ2jx2VL9w6dR7TcJQn0CRjLZwn4oNkBetzeSEGX2RgkXrgDWZl50Khz+vkMdhT64igJSXO/wWKjA6rRcCJcYwO08k+9JCbMLmx6eBULniB2DkO0i7TL3hvm6PIX7Img1Cj9thxh7ykEoEhuaDZfXvLf9G7l+YuthWszDTLTCJL4V8RoOlp4v21ZC7Lnr4xGC3uYLr/+U1Y7zGv8DNqGcAwRoQhlKDYtqSN8AgZQyiKwuiZE+Q9OXskK3HA4x6bRR7eBZEB5peAlMmBImCn/l7RnRAgpNScDfB4Kf4+8ffWZrhm05IqI1KVoa2d5Jg1EtXiREmyLXmUe+lv4bGAfS/OASwtzBehBb04QwZVXFyrBs/NDn2yOaJxioI7rIKbZYZAYlnXmIhd0TRCR/74Qs4wU2UPwZdPiyAy8md7tIwNL8WqImO6ZB8DKNs1T2VLLQ7zCh2C0iUftAKAFihQggoBYX3v2bAbQWx+eHjcDxLy3oEi2cpRnkPvE/pz2rD6HLksbvKOdrFKhbTftQWWxgsnDToAihC4VVbC

tbrackett
Newbie
Posts: 11
Joined: Wed Dec 07, 2005 5:00 pm

Re: AESENCRYPT help

Post by tbrackett » Fri Jul 06, 2018 8:40 pm

One last thing - I noticed that the unicode is UTF-16LE rather than UTF-16- I don't think that is causing the mismatch but.....

tbrackett
Newbie
Posts: 11
Joined: Wed Dec 07, 2005 5:00 pm

Re: AESENCRYPT help

Post by tbrackett » Wed Jul 18, 2018 6:43 pm

A HUGE THANK YOU to Marcus for tweaking the AES encryption and solved all my problems!!!
Now Macroscheduler can encrypt to NSA standards!!! :P

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: AESENCRYPT help

Post by Marcus Tettmar » Wed Jul 18, 2018 11:05 pm

No problem, and thanks for your help.

Macro Scheduler 14.4.09 with improved AESEncrypt function is now available.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts