MTM-RouterOS-Scripting icon indicating copy to clipboard operation
MTM-RouterOS-Scripting copied to clipboard

SHA256 and HEX

Open nhosseinzadeh opened this issue 2 years ago • 8 comments

hello, could please add the SHA256 hashing function and also HEX encryption to this amazing repository for ROS 7? thanks for sharing your works

nhosseinzadeh avatar Mar 04 '23 06:03 nhosseinzadeh

Hi, What do you mean by HEX encryption?

merlinthemagic avatar Mar 04 '23 20:03 merlinthemagic

Hi, i mean ASCII String to HEX and Decimal number to HEX

nhosseinzadeh avatar Mar 07 '23 09:03 nhosseinzadeh

The SHA family is more than a 15min job, so its not going to happen anytime soon. But I implemented a mostly working version of ASCII to base16. Check out the "class" and see if you can contribute the decode function :)

##string to encode in base16 /hexadecimal
:local myStr "My string";

/import flash/MTM/Facts.rsc;
:global MtmFacts;
:local toolObj [($MtmFacts->"get") "getTools()->getEncoding()->getBase16()"];
:put ([($toolObj->"encode") $myStr]); #4D7920737472696E67

merlinthemagic avatar Mar 09 '23 18:03 merlinthemagic

You just copied my concept, not the working Base64 function... I have finished both encoding and decoding, if you want to copy them you can find them in the usual place. https://forum.mikrotik.com/viewtopic.php?p=988931#p988931

rextended avatar Mar 10 '23 11:03 rextended

@rextended Hi,I was gathering notes on base64 and saw your example. You are right its not ready, nor pulled out as a factory method yet.

But, if i have your permission I would love to port your functions to MTM, with proper attribution of course.

merlinthemagic avatar Mar 10 '23 11:03 merlinthemagic

No problems.

It's also present the decode function.

rextended avatar Mar 10 '23 12:03 rextended

@rextended

Did not have time to fully understand the opts you handle, so the initial version does not include them. https://github.com/merlinthemagic/MTM-RouterOS-Scripting/blob/main/src/v7/flash/MTM/Tools/Encoding/Base64.rsc

Let me know if you want the attribution to say something different.

merlinthemagic avatar Mar 10 '23 13:03 merlinthemagic

No, it's ok. For the options... are optionals ;)

rextended avatar Mar 10 '23 16:03 rextended