diff options
author | Christian Hesse <mail@eworm.de> | 2020-06-18 12:23:50 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-06-18 12:23:50 +0200 |
commit | a1d05f93c658b79ece0565241fd3fce882ac99cd (patch) | |
tree | f9fe63aed120734a2f3601ccdaaeac653d0ad146 /global-functions | |
parent | 35894168408096ce7e33c52bf06b5ad80d3493d1 (diff) |
global-functions: add $GetRandomSha256
Diffstat (limited to 'global-functions')
-rw-r--r-- | global-functions | 12 |
1 files changed, 12 insertions, 0 deletions
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 ]; |