Skip to content

SHA-2 implements in Sysmac Studio.

License

Notifications You must be signed in to change notification settings

kmu2030/SHA2Lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SHA2Lib

SHA2Lib provides a SHA-2 digest generation FB for Sysmac Studio. OMRON's Sysmac Studio is required to view and execute the code.

Environment

Sysmac Studio Version 1.60

How to use "SHA2Lib.slr"

  1. git clone this repository or download the zip.
  2. Reference "SHA2Lib.slr" in your project.

Also check "SHA2LibExample.smc2".

How to use "SHA2LibExample.smc2"

  1. git clone this repository or download the zip.
  2. Open "SHA2LibExample.smc2" in Sysmac Studio.
  3. Check "POU/Program/README".
  4. Build the project.
  5. Execute on simulator or actual machine.

"SHA2LibExample.smc2" includes "SHA2Lib.slr".

Explanation

SHA2Lib provides SHA-2 digest generation FB. FB generates a digest from an input sequence of bytes.

CASE iState OF
    0:
        iMessage := 'abc'; // ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
        iBinMessageSize := StringToAry(In:=iMessage,
                                       AryOut:=iBinMessage[0]);
        iBinMessageHead := 0;
        iSHA256StreamDigest(Execute:=FALSE,
                            Stream:=iBinMessage,
                            StreamHead:=iBinMessageHead);
		
        Inc(iState);
    1:
        WHILE NOT iSHA256StreamDigest.Done DO
            iSHA256StreamDigest(Execute:=TRUE,
                                Stream:=iBinMessage,
                                StreamHead:=iBinMessageHead,
                                StreamSize:=iBinMessageSize,
                                HashStr=>iHashStr);
        END_WHILE;
		
        Inc(iState);
END_CASE;

File hash

I recommend checking the hash value of the acquired Sysmac Studio project.

file sha256
SHA2Lib.slr 24eb0ce5a686a9abc1acf75a8771ae83c045fe64065ca6bc973aba9c1a16eb0e
SHA2LibExample.scm2 69850dc8b24f7b2726c4080705a07000e47255231db5949134459e1fc4fc1189