Documentation
¶
Overview ¶
Package HMACContext provides methods for working with HMACContext object instances.
Index ¶
- type Advanced
- type Any
- type Instance
- func (self Instance) AsHMACContext() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) Finish() []byte
- func (self Instance) Start(hash_type gdclass.HashingContextHashType, key []byte) error
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Update(data []byte) error
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Instance ¶
type Instance [1]gdclass.HMACContext
The HMACContext class is useful for advanced HMAC use cases, such as streaming the message as it supports creating the message over time rather than providing it all at once. [codeblocks] [gdscript] extends Node var ctx = HMACContext.new()
func _ready():
var key = "supersecret".to_utf8_buffer() var err = ctx.start(HashingContext.HASH_SHA256, key) assert(err == OK) var msg1 = "this is ".to_utf8_buffer() var msg2 = "super duper secret".to_utf8_buffer() err = ctx.update(msg1) assert(err == OK) err = ctx.update(msg2) assert(err == OK) var hmac = ctx.finish() print(hmac.hex_encode())
[/gdscript] [csharp] using Godot; using System.Diagnostics;
public partial class MyNode : Node
{ private HmacContext _ctx = new HmacContext(); public override void _Ready() { byte[] key = "supersecret".ToUtf8Buffer(); Error err = _ctx.Start(HashingContext.HashType.Sha256, key); Debug.Assert(err == Error.Ok); byte[] msg1 = "this is ".ToUtf8Buffer(); byte[] msg2 = "super duper secret".ToUtf8Buffer(); err = _ctx.Update(msg1); Debug.Assert(err == Error.Ok); err = _ctx.Update(msg2); Debug.Assert(err == Error.Ok); byte[] hmac = _ctx.Finish(); GD.Print(hmac.HexEncode()); } }
[/csharp] [/codeblocks]
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsHMACContext ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) Finish ¶
Returns the resulting HMAC. If the HMAC failed, an empty [PackedByteArray] is returned.
func (Instance) Start ¶
func (self Instance) Start(hash_type gdclass.HashingContextHashType, key []byte) error
Initializes the HMACContext. This method cannot be called again on the same HMACContext until [method finish] has been called.