clarity-lang / reference

The Clarity Reference
149 stars 34 forks source link

Support strings as parameters in hashing functions #72

Open ameeratgithub opened 10 months ago

ameeratgithub commented 10 months ago

It's not convenient to use hashing functions like hash160, sha256 and sha512 because they accept buffers as inputs. We can't use to-consensus-buff? directly without a workaround like this.

(let ((s "hello, world")) (slice? (try! (to-consensus-buff? s)) u5 (+ u5 (len s))))

Hashing functions should support strings as parameters. There should be a re-usable function, may be to-buff?, that contains above logic.