2
0

Digest.hx 699 B

12345678910111213141516171819
  1. package sys.ssl;
  2. import cpp.NativeSsl;
  3. @:coreApi
  4. class Digest {
  5. public static function make( data : haxe.io.Bytes, alg : DigestAlgorithm ) : haxe.io.Bytes {
  6. return haxe.io.Bytes.ofData( NativeSsl.dgst_make( data.getData(), alg ) );
  7. }
  8. public static function sign( data : haxe.io.Bytes, privKey : Key, alg : DigestAlgorithm ) : haxe.io.Bytes {
  9. return haxe.io.Bytes.ofData( NativeSsl.dgst_sign( data.getData(), @:privateAccess privKey.__k, alg ) );
  10. }
  11. public static function verify( data : haxe.io.Bytes, signature : haxe.io.Bytes, pubKey : Key, alg : DigestAlgorithm ) : Bool{
  12. return NativeSsl.dgst_verify( data.getData(), signature.getData(), @:privateAccess pubKey.__k, alg );
  13. }
  14. }