Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to properly use Cryptohash lib

Featured Replies

Posted

Hi masters,

I am new here on tuts4you.

I need help of you guys.

I am coding an personal hasher tool in ASM with the help of cryptohash lib.

I am having problem with EnCrypters like MARS

It's not giving me proper hash and not decryting it too.

Here is a piece of code, I have coded.


invoke GetDlgItemText,hWin,EDIT_KEY,addr key,sizeof key
mov keysize,eax
invoke GetDlgItemText,hWin,EDIT_INPUT,addr inbuff,sizeof inbuff
invoke MARSSetKey,addr key,keysize
invoke MARSEncrypt,addr inbuff,addr hash
invoke HexEncode,addr hash,16,addr outbuff
invoke SetDlgItemText,hWin,EDIT_HASH,addr outbuff
invoke RtlZeroMemory,addr inbuff,sizeof inbuff
invoke MARSDecrypt,addr outbuff,addr inbuff
invoke SetDlgItemText,hWin,EDIT_DECRYPTEDHASH,addr inbuff

For more, I have attached my project of winASM, kindly solve the issue.

If possible please tell me how to use all Encrypters of cryptohash.

Thanking you

RETN

New Folder.zip

1) MARS is a block cipher, and MARSEncrypt encrypts one block (128bits = 16bytes) at a time

2) If input was less than 16 bytes, your code will encrypt some garbage too.

3) Before decrypting *perhaps* you should set the decryption key again.

4) But the biggest problem is here:


invoke GetDlgItemText,hWin,EDIT_KEY,addr key,sizeof key
mov keysize,eax
invoke GetDlgItemText,hWin,EDIT_INPUT,addr inbuff,sizeof inbuffinvoke MARSSetKey,addr key,keysize
invoke MARSEncrypt,addr inbuff,addr hash ----> encrypted output goes to "hash".
invoke HexEncode,addr hash,16,addr outbuff ----> "outbuff" now contains string representation of encrypted data
invoke SetDlgItemText,hWin,EDIT_HASH,addr outbuffinvoke RtlZeroMemory,addr inbuff,sizeof inbuff
invoke MARSDecrypt,addr outbuff,addr inbuff ----> you should decrypt "hash", not outbuff.
invoke SetDlgItemText,hWin,EDIT_DECRYPTEDHASH,addr inbuff

Nice question and Nice answer Kao, it will be useful.

Thanks

  • Author

Thanks Kao,

But help me on this.

I am using Rijandael and XTEA from cryptolib and having two different problems.

When Using Rijandael the program crashes when I click on Calculate and when

I am using XTEA the program hangs.

Here are codes :

XTEA :


invoke XTEAInit,addr key,addr keysize
invoke XTEAEncrypt,addr instring,addr tempbuff
invoke HexEncode,addr tempbuff,bvalue,addr outstring
invoke SetDlgItemInt,hWin,1038,bvalue,0
invoke SetDlgItemText,hWin,1024,addr outstring
  • Author

Thanks Kao,

But help me on this.

I am using Rijandael and XTEA from cryptolib and having two different problems.

When Using Rijandael the program crashes when I click on Calculate and when

I am using XTEA the program hangs. :confused:

Here are codes :

XTEA :


invoke XTEAInit,addr key,addr keysize ; keysize is length of key
invoke XTEAEncrypt,addr instring,addr tempbuff
invoke HexEncode,addr tempbuff,16,addr outstring
invoke SetDlgItemText,hWin,1024,addr outstring

Rijandael :

invoke RijndaelInit,addr key,keysize
invoke RijndaelEncrypt,addr instring,addr tempbuff
invoke HexEncode,addr tempbuff,bvalue,addr outstring
invoke SetDlgItemInt,hWin,1038,bvalue,0
invoke SetDlgItemText,hWin,1024,addr outstring

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.