| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-03-04 15:26:28 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-03-04 15:26:28 UTC |
| parent | 4877e9f706a9efc10a62f602078f4b4408e1696d |
| snikket/Hash.hx | +10 | -0 |
diff --git a/snikket/Hash.hx b/snikket/Hash.hx index dbcc0e0..28e862b 100644 --- a/snikket/Hash.hx +++ b/snikket/Hash.hx @@ -1,5 +1,7 @@ package snikket; +import haxe.crypto.Sha1; +import haxe.crypto.Sha256; import haxe.crypto.Base64; import haxe.io.Bytes; import haxe.io.BytesData; @@ -52,6 +54,14 @@ class Hash { return null; } + public static function sha1(bytes: Bytes) { + return new Hash("sha-1", Sha1.make(bytes).getData()); + } + + public static function sha256(bytes: Bytes) { + return new Hash("sha-256", Sha256.make(bytes).getData()); + } + public function toUri() { if (Config.relativeHashUri) { return "/.well-known/ni/" + algorithm.urlEncode() + "/" + toBase64Url();