2024-08-25 04:08:24 +00:00
|
|
|
package qt
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qcryptographichash.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
type QCryptographicHash__Algorithm int
|
|
|
|
|
|
|
|
const (
|
2024-09-20 07:13:26 +00:00
|
|
|
QCryptographicHash__Md4 QCryptographicHash__Algorithm = 0
|
|
|
|
QCryptographicHash__Md5 QCryptographicHash__Algorithm = 1
|
|
|
|
QCryptographicHash__Sha1 QCryptographicHash__Algorithm = 2
|
|
|
|
QCryptographicHash__Sha224 QCryptographicHash__Algorithm = 3
|
|
|
|
QCryptographicHash__Sha256 QCryptographicHash__Algorithm = 4
|
|
|
|
QCryptographicHash__Sha384 QCryptographicHash__Algorithm = 5
|
|
|
|
QCryptographicHash__Sha512 QCryptographicHash__Algorithm = 6
|
|
|
|
QCryptographicHash__Keccak_224 QCryptographicHash__Algorithm = 7
|
|
|
|
QCryptographicHash__Keccak_256 QCryptographicHash__Algorithm = 8
|
|
|
|
QCryptographicHash__Keccak_384 QCryptographicHash__Algorithm = 9
|
|
|
|
QCryptographicHash__Keccak_512 QCryptographicHash__Algorithm = 10
|
|
|
|
QCryptographicHash__RealSha3_224 QCryptographicHash__Algorithm = 11
|
|
|
|
QCryptographicHash__RealSha3_256 QCryptographicHash__Algorithm = 12
|
|
|
|
QCryptographicHash__RealSha3_384 QCryptographicHash__Algorithm = 13
|
|
|
|
QCryptographicHash__RealSha3_512 QCryptographicHash__Algorithm = 14
|
|
|
|
QCryptographicHash__Sha3_224 QCryptographicHash__Algorithm = 11
|
|
|
|
QCryptographicHash__Sha3_256 QCryptographicHash__Algorithm = 12
|
|
|
|
QCryptographicHash__Sha3_384 QCryptographicHash__Algorithm = 13
|
|
|
|
QCryptographicHash__Sha3_512 QCryptographicHash__Algorithm = 14
|
2024-09-04 06:54:22 +00:00
|
|
|
)
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
type QCryptographicHash struct {
|
2024-11-19 06:29:06 +00:00
|
|
|
h *C.QCryptographicHash
|
|
|
|
isSubclass bool
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCryptographicHash) cPointer() *C.QCryptographicHash {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
2024-10-16 05:07:56 +00:00
|
|
|
func (this *QCryptographicHash) UnsafePointer() unsafe.Pointer {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return unsafe.Pointer(this.h)
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// newQCryptographicHash constructs the type using only CGO pointers.
|
2024-08-25 04:08:24 +00:00
|
|
|
func newQCryptographicHash(h *C.QCryptographicHash) *QCryptographicHash {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QCryptographicHash{h: h}
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// UnsafeNewQCryptographicHash constructs the type using only unsafe pointers.
|
2024-10-16 05:07:56 +00:00
|
|
|
func UnsafeNewQCryptographicHash(h unsafe.Pointer) *QCryptographicHash {
|
2024-11-19 06:29:06 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &QCryptographicHash{h: (*C.QCryptographicHash)(h)}
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
// NewQCryptographicHash constructs a new QCryptographicHash object.
|
2024-09-04 06:54:22 +00:00
|
|
|
func NewQCryptographicHash(method QCryptographicHash__Algorithm) *QCryptographicHash {
|
2024-11-19 06:29:06 +00:00
|
|
|
var outptr_QCryptographicHash *C.QCryptographicHash = nil
|
|
|
|
|
|
|
|
C.QCryptographicHash_new((C.int)(method), &outptr_QCryptographicHash)
|
|
|
|
ret := newQCryptographicHash(outptr_QCryptographicHash)
|
|
|
|
ret.isSubclass = true
|
|
|
|
return ret
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QCryptographicHash) Reset() {
|
|
|
|
C.QCryptographicHash_Reset(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCryptographicHash) AddData(data string, length int) {
|
|
|
|
data_Cstring := C.CString(data)
|
|
|
|
defer C.free(unsafe.Pointer(data_Cstring))
|
|
|
|
C.QCryptographicHash_AddData(this.h, data_Cstring, (C.int)(length))
|
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
func (this *QCryptographicHash) AddDataWithData(data []byte) {
|
|
|
|
data_alias := C.struct_miqt_string{}
|
|
|
|
data_alias.data = (*C.char)(unsafe.Pointer(&data[0]))
|
|
|
|
data_alias.len = C.size_t(len(data))
|
|
|
|
C.QCryptographicHash_AddDataWithData(this.h, data_alias)
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCryptographicHash) AddDataWithDevice(device *QIODevice) bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QCryptographicHash_AddDataWithDevice(this.h, device.cPointer()))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
func (this *QCryptographicHash) Result() []byte {
|
|
|
|
var _bytearray C.struct_miqt_string = C.QCryptographicHash_Result(this.h)
|
|
|
|
_ret := C.GoBytes(unsafe.Pointer(_bytearray.data), C.int(int64(_bytearray.len)))
|
|
|
|
C.free(unsafe.Pointer(_bytearray.data))
|
|
|
|
return _ret
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
func QCryptographicHash_Hash(data []byte, method QCryptographicHash__Algorithm) []byte {
|
|
|
|
data_alias := C.struct_miqt_string{}
|
|
|
|
data_alias.data = (*C.char)(unsafe.Pointer(&data[0]))
|
|
|
|
data_alias.len = C.size_t(len(data))
|
|
|
|
var _bytearray C.struct_miqt_string = C.QCryptographicHash_Hash(data_alias, (C.int)(method))
|
|
|
|
_ret := C.GoBytes(unsafe.Pointer(_bytearray.data), C.int(int64(_bytearray.len)))
|
|
|
|
C.free(unsafe.Pointer(_bytearray.data))
|
|
|
|
return _ret
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func QCryptographicHash_HashLength(method QCryptographicHash__Algorithm) int {
|
2024-09-18 00:12:02 +00:00
|
|
|
return (int)(C.QCryptographicHash_HashLength((C.int)(method)))
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
// Delete this object from C++ memory.
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QCryptographicHash) Delete() {
|
2024-11-19 06:29:06 +00:00
|
|
|
C.QCryptographicHash_Delete(this.h, C.bool(this.isSubclass))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
2024-09-14 22:29:05 +00:00
|
|
|
|
|
|
|
// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
|
|
|
|
// from C++ memory once it is unreachable from Go memory.
|
|
|
|
func (this *QCryptographicHash) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QCryptographicHash) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|