Jump to content

Convert Binary Hash returned by _Crypt to String


Recommended Posts

@Radiance 0x1B17F2D9AB91B2D6E78C30A0E71F0EB5 is currently in integer form... if it was a string it would be easy :P

 

_Crypt_Hash* functions return hashes in 0x (hexadecimal?) form, I am trying to compare 2 hashes, one in string form and another in integer (0x) form :)

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

@czardas I was not sure about that... I got that error too but _Crypt_Hash* is returning it in integer form Just checked it using VarGetType, it says that it is Binary :blink:

 

Sorry everyone, please give me a minute to recollect all my thoughts >_<

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

Yep, I got a handle in the situation now :D:

Here is what I came up with:

#include <Crypt.au3>

Local $dHash = _Crypt_HashFile(@ScriptDir & '\test', $CALG_MD5)

ConsoleWrite($dHash & @CRLF) ; Binary Form
ConsoleWrite(StringTrimLeft(BinaryToString($dHash), 2)) ; This is the MD5 hash in string form

TD :)

Edited by TheDcoder
Corrected Code

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Colduction
      Hi AutoIt programmers, excuse me for bothering you with multiple topics.

      In AutoIt we can use Number() function to convert Hex string to number but it's output is different of C# output & and i wanna make it's output like AutoIt code.

      For e.g I use this in AutoIt:
      Local $dBinary = Binary("Hello") ; Create binary data from a string. Local $dExtract = Number(BinaryMid($dBinary, 1, 5)) ConsoleWrite($dExtract & @CRLF) And i use this for C#:
      using System; using System.Text; //NameSpace Is Use of Project Name namespace TEST { class Program { public static void Main(string[] args) { //declaring a variable and assigning hex value string dd = ToHex("Hello", Encoding.ASCII); decimal d = Int64.Parse(dd, System.Globalization.NumberStyles.HexNumber); Console.WriteLine("Result: " + d); //hit ENTER to exit Console.ReadLine(); } public static string ToHex(string sInput, Encoding oEncoding, bool b0x_Prefix = false) { byte[] a_binaryOutput = oEncoding.GetBytes(sInput); string sOutput = BitConverter.ToString(a_binaryOutput).Replace("-", ""); if (b0x_Prefix == false) { return sOutput; } else { return "0x" + sOutput; } } } }
      I say once again that excuse me for creating new topic, in fact i'm making a library for GAuthOTP from a topic in AutoIt.
    • By jmor
      For some reason, I can't convert to Hex a Decimal color that has been calculated.
      For example, this works:
      Local $iColor = 3310546 ConsoleWrite("$iColor (dec): " & $iColor & ", $iColor (hex): " & Hex($iColor, 6) & @CRLF) giving the expected output:
      $iColor (dec): 3310546, $iColor (hex): 3283D2
      But if I want to take an average of several colors, I have a problem.  For example this doesn't work:
      $iColor = (3310546 + 3310546) / 2 ConsoleWrite("$iColor (dec): " & $iColor & ", $iColor (hex): " & Hex($iColor, 6) & @CRLF) giving the wrong output:
      $iColor (dec): 3310546, $iColor (hex): 000000
      I observe this behavior after any processing of a decimal color.
      Is this a bug?
    • By cruisepandey
      Hi, 
      I have a string like this : 
      Global $Msga = "urrent directory is /send.  (Submission of file with log number 29381077284 is confirmed)";
      I want to extract the number 29381077284  from the string. I did StringSplit to split based on "(" and then use space to reach there, But it's not a good choice. 
      Can anyone help me with regular expression to find the number from String using AutoIT. TIA
    • By DannyJ
      I have this example string:
       
      2020-06-08 09:23:33 : abcdefghifjklm How to trim just the right part? Or how to trim this text right to left?
      I want to trim this string right to left until ' : '.
      In ohter words: I need the 'abcdefghifklm' text.
      I have tried StringTrimRight, but that requires 
      The number of characters to trim. Unfortunately StringSplit trims the left part of the strings.
       
       
    • By careca
      This is my take on string triggers, triggers on specific strings.
      Able to simple text pasting,
      opening links (as long as there's a www. http:\\ or https:\\ at the beggining)
      and is able to open applications, if there is a parameter in the parameter field, it uses it.
      Shows your external, lan, and gateway ip's.
      Able to change system volume by a set percentage, reading from the inputbox the number the user sets, if 0 or empty uses system default.
      I made this because the existing string trigger applications didn't do it for me.
      I did this for me, but if someone finds it useful, all the better.
×
×
  • Create New...