Page 1 of 1

[ASK] -- Calculate Hash Using algorithm MD5 or SHA1

Posted: 04 Jul 2015 06:16
by Diantokam
Dear All,

I'm new on automagic and i can't write script, please help me how to calculate hash using MD5 or SHA1

Condition :

I have 2 file :
--> file-01.txt
--> file-02.txt

What i want is :

--> CHECK both HASH file, it can be using MD5 or SHA1

--> COMPARING both file, to see if file is the same

--> LOGING the comparing result.


Is anyone here can help me, i'm already searching on this forum and can't find any reference how to check HASH file.


Thank You

Re: [ASK] -- Calculate Hash Using algorithm MD5 or SHA1

Posted: 05 Jul 2015 11:27
by Martin
Hi,

Automagic currently only supports to create a hash within an action Script from an input text.
Following flows could work:
-action Action Init Variable Text File: file1.txt to file_text1
-action Action Init Variable Text File: file2.txt to file_text2
-action Script with:

Code: Select all

h1 = hash(file_text1, "utf-8", "sha1");//or "md5"
h2 = hash(file_text2, "utf-8", "sha1");//or "md5"
log(h1==h2);//either logs true or false
You could also use a condition Expression to check if the hashes are the same (almost the same as above):
-action Action Init Variable Text File: file1.txt to file_text1
-action Action Init Variable Text File: file2.txt to file_text2
-condition Expression with:

Code: Select all

h1 = hash(file_text1, "utf-8", "sha1");//or "md5"
h2 = hash(file_text2, "utf-8", "sha1");//or "md5"
h1==h2;
--> true: action Notification on Screen: files are the same
--> false: action Notification on Screen: files are not the same

Alternatively you could also read and check the output of command md5 which is available on many ROMs (action Execute Command: md5 file1.txt).

Regards,
Martin

Re: [ASK] -- Calculate Hash Using algorithm MD5 or SHA1

Posted: 05 Jul 2015 22:25
by Diantokam
Thank You Martin>>> <<(ง°▼°)ง