From a1d05f93c658b79ece0565241fd3fce882ac99cd Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 18 Jun 2020 12:23:50 +0200 Subject: global-functions: add $GetRandomSha256 --- global-functions | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'global-functions') diff --git a/global-functions b/global-functions index 4bc0d0b..a37ce5d 100644 --- a/global-functions +++ b/global-functions @@ -28,6 +28,7 @@ :global DownloadPackage; :global GetMacVendor; :global GetRandom; +:global GetRandomSha256; :global LogPrintExit; :global MailServerIsUp; :global MkDir; @@ -316,6 +317,17 @@ :return ($Sum % $Max); } +# generate random sha256 string +# returns 64 bytes of 0-9 and a-f +:set GetRandomSha256 do={ + :local FingerPrint; + / certificate add name=GetRandomSha256-template common-name=GetRandomSha256 key-size=prime256v1; + / certificate sign GetRandomSha256-template name=GetRandomSha256 without-paging as-value; + :set FingerPrint [ / certificate get GetRandomSha256 fingerprint ]; + / certificate remove GetRandomSha256; + :return $FingerPrint; +} + # log and print with same text, optionally exit :set LogPrintExit do={ :local Severity [ :tostr $1 ]; -- cgit v1.2.3-54-g00ecf