merlinthemagic / MTM-RouterOS-Scripting

An on demand loaded library of functions for ROS scripting
GNU Lesser General Public License v3.0
21 stars 6 forks source link

SHA256 and HEX #2

Open nhosseinzadeh opened 1 year ago

nhosseinzadeh commented 1 year ago

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

merlinthemagic commented 1 year ago

Hi, What do you mean by HEX encryption?

nhosseinzadeh commented 1 year ago

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

merlinthemagic commented 1 year ago

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
rextended commented 1 year ago

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

merlinthemagic commented 1 year ago

@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.

rextended commented 1 year ago

No problems.

It's also present the decode function.

merlinthemagic commented 1 year ago

@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.

rextended commented 1 year ago

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