mIRC Home    About    Download    Register    News    Help

Print Thread
#263011 11/05/18 03:36 PM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Would be helpful to be able to specify an output encoding for all hashing identifiers.

Currently to use non-hex encoding we have to:
- hash
- loop over result converting to decimal
- store each converted value in a bvar
- convert bvar to desired encoding
Which can be quite a bit of overhead to undo something mIRC is doing by default

I propose supporting mime/base64 encoding natively and an option to output the result to a bvar similar to the way $encode/encode work

Code:
$sha256(input, [N]oN, &output)
  N = 0: input is plain text
  N = 1: input is bvar
  N = 2: input is filename

  o0: Output should not be encoded
  o1: Output should be hex encoded (default)
  o2: Output should be mime/base64 encoded

  &output: bvar to store the result in
    if specified, the number of bytes wrote to the bvar is returned
    The bvar is cleared before the result is output into it


* $sha256 used as an example

Last edited by FroggieDaFrog; 11/05/18 06:12 PM.

I am SReject
My Stuff
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Another syntax method would be to use switch letters similar to the way $encode does it, using the same switch letters plus another for hex:

Quote:

o0 -> t = text
o1 -> h = hex base16 (default)
o2 -> m = mime
o3 -> u = uuencode
o4 -> a = base32
b = encoded string is instead sent to parameter &binvar, and normal output is instead the number of bytes put into &binvar


(and possibly another switch letter for Base85)
https://forums.mirc.com/ubbthreads.php/topics/263013

I'm assuming it's easier for an identifier to have the switches be a separate parameter rather than joining with the current digits 0/1/2.

Quote:

var %a $sha1($mircini,2,m) = hash of mirc.ini to %a encoded as mime (mime of the 20 binary bytes of the binary hash output, not mime of the 40 hex text characters)
var %a $sha1(abc,,m) = mime string to %a ($null 2nd parm handled as default 0)
var %a $sha1(dspx,,tb,&binvar) = 20 binary bytes to &binvar including 0x00's, %a contains $bvar(&binvar,0)
var %a $sha1(dspx,,t) = %a contains text string chopped at the first encountered 0x00 if any


Link Copied to Clipboard