rejetto forum

Author Topic: Implementing Base64 encoding/decoding as a Macro function  (Read 14317 times)

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 2059
    • View Profile
Re: base64 Re: Responsive small screen template
« on: October 31, 2018, 09:58:01 PM »

But I was wondering if is it possible make HFS decode Base64 'on-the-fly' using a macro like: {.mime|text/css;base64.}

Also, neither of the following works:

Code: [Select]
[mystyle.css]
{.base64|YSB7dGV4dC1kZWNvcmF0aW9uOiBub25lfQ==.}

Code: [Select]
[mystyle.css]
{.base64decode|YSB7dGV4dC1kZWNvcmF0aW9uOiBub25lfQ==.}

I'm curious to know if this is possible using macros. ???

it would be enough simply to add this in scriptlib.pas before 'encodeuri'

Quote
    if name = 'encode64' then
      result:=base64encode(p);

    if name = 'decode64' then
      result:=base64decode(p);
      

including OverbyteicsMD5and OverbyteicsSha1 in the uses,we can allow two other codifications

 
Quote
   if name = 'encodemd5' then
      result:=strMD5(p);

    if name = 'encodesha1' then
      result:=SHA1ofStr(p);   

the latter two can be used to code the sending of a verification code or password

a wacky example as how encrypt download url and redirect it to be managed in a section

   
Quote
   {.if|{.=|%item-type%|folder.}|<a href="%item-url%">|<a href="/~download?name=%item-name%&id={.encode64|%item-full-url%.}&md5={.encodemd5|%item-url%.}">.}

[download|no log]
<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="0; url={.decode64|{.urlvar|id.}.}">
        <script type="text/javascript">
            window.location.href = "{.decode64|{.urlvar|id.}.}"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
        <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
        If you are not redirected automatically, follow this <a href='{.decode64|{.urlvar|id.}.}'>direct link </a>.
    </body>
</html>
   

Follow members gave a thank to your post:


Thank-o-Matic 3.0 By Adk Team