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

Post your questions and help other users.

Moderator: Martin

Post Reply
Diantokam
Posts: 6
Joined: 04 Jul 2015 06:02

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

Post by Diantokam » 04 Jul 2015 06:16

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

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

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

Post by Martin » 05 Jul 2015 11:27

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

Diantokam
Posts: 6
Joined: 04 Jul 2015 06:02

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

Post by Diantokam » 05 Jul 2015 22:25

Thank You Martin>>> <<(ง°▼°)ง

Post Reply