Support for $bvar hex output and hex input for binary commands would be helpful when using $bfind().regex

While normally $bfind returns the position of the match, the .regex prop makes it return the number of matches instead of a position within the binvar, so your regex pattern must use a capture group and you must use $regml([name,]N).pos to find that position. However to make a regex match, in a binary string which doesn't contain UTF8 text, requires using \xNN where NN is a hex value 00-FF

Also, if /bset /breplace support input of replacement strings using the same hex alphabet, that would make things simpler and avoid miss-steaks.

Perhaps a .hex prop for $bvar to change the output to 2-digit hex, and a -x switch so the /bcommands would see the byte values (but not the position) as hex.

Here's some scripted aliases to sorta do what I'm suggesting.

Code
alias bset {
  if ($isid) { echo -sc info * No such identifier: $bset | halt }
  if (-* iswm $1) {
    if ((x isin $1) && (t isin $1)) { echo -sc info /bset don't use -x AND -t | halt }
    var %pattern /([0-9a-fA-F]{1,2})/g
    bset $1-3 $regsubex(foo,$4-,%pattern,$base(\t,16,10) $+ $chr(32))
  }
  else !bset $1-
}


//bset -x &v 1 61 62 63 | echo -a $bvar(&v,1-).text
result: abc

Code
alias breplace {
  if ($isid) { echo -sc info * No such identifier: $breplace | halt }
  if ($1 == -x) breplace $2 $regsubex(foo,$3-,/([0-9a-fA-F]+)/g,$base(\t,16,10))
  else !breplace $1-
}


//bset &v 1 1 2 3 255 4 5 6 | breplace -x &v ff fe | echo -a $bvar(&v,1-)
result: 1 2 3 254 4 5 6

Code
alias bvar2hex {
  if ($2 == $null) var %range 1- | else var %range $2 | if ($3) var %range $+($2,-,$calc($2 +$3 -1))
  if ($1) return $regsubex($iif(&* iswm $1,$bvar($1,%range),$1),/(\d+)/g,$base(\t,10,16,2) $iif(dot isin $prop && (!$calc(\n % 8)),. $+ $chr(32)))
  echo -sc info *bvar2hex(list of base10's) *$bvar2hex(&binvar) *$bvar2hex(&binvar,N|N-|N1-N2) *$bvar2hex(&binvar,offset,length) [.dot] formats output into groups of 8
}


//bset -x &v 1 $sha1(abc) | echo -a $bvar2hex(&v,1-)
result: A9 99 3E 36 47 06 81 6A BA 3E 25 71 78 50 C2 6C 9C D0 D8 9D

The /bset alias allows hex values to be bunched together, but if the token length is odd, the '0' is padded in front of the 1st output token created from it.

//bset -x &v 1 abcde 1 2 34 5 | echo -a $bvar2hex(&v,1-)
result: 0A BC DE 01 02 34 05

To improve readibility of the hex output, I added an option to have a period following every 8th byte.

//bset &v 1 $regsubex(foo,$str(x,94),/x/g,$calc(32+ \n) $+ $chr(32)) | echo -a $bvar2hex(&v).dot

If you have the base10 byte values and just want the hex equivalents:

//echo -a $bvar2hex(00 11 22 33 44 55 66 77 88 99 111)
result: 00 0B 16 21 2C 37 42 4D 58 63 6F

It's hard for the $bvar2hex alias to estimate whether the output from range 1- fits within the line length, because the byte value obtained from $bvar has a variable 1-3 length each, while the hex output is fixed at 2 each. So, to be safe, should probably limit output to a range of $maxlenl *1/4 values.