Skip to content

Instantly share code, notes, and snippets.

View wqweto's full-sized avatar

Vladimir Vissoultchev wqweto

View GitHub Profile
@wqweto
wqweto / mdSha2.bas
Last active April 17, 2023 07:22
[VB6/VBA] Pure VB6 implementation of SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/256 and SHA-512/224 incl. HMAC
'--- mdSha2.bas
Option Explicit
DefObj A-Z
#Const HasSha512 = (CRYPT_HAS_SHA512 <> 0)
#Const HasPtrSafe = (VBA7 <> 0)
#Const HasOperators = (TWINBASIC <> 0)
#If HasPtrSafe Then
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
@wqweto
wqweto / FM20.IDL
Last active April 4, 2023 18:24
Typelib resource ID 3 from MSVBVM60.DLL
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: FM20.DLL
[
uuid(0D452EE1-E08F-101A-852E-02608C4D0BB4),
version(2.0),
helpstring("Microsoft Forms 2.0 Object Library"),
helpfile("fm20.hlp"),
helpcontext(00000000),
@wqweto
wqweto / TextBoxW.ctl
Last active March 31, 2023 10:48
Krool's TextBoxW using MST
Option Explicit
#If False Then
Private TxtCharacterCasingNormal, TxtCharacterCasingUpper, TxtCharacterCasingLower
Private TxtIconNone, TxtIconInfo, TxtIconWarning, TxtIconError
Private TxtNetAddressFormatNone, TxtNetAddressFormatDNSName, TxtNetAddressFormatIPv4, TxtNetAddressFormatIPv6
Private TxtNetAddressTypeNone, TxtNetAddressTypeIPv4Address, TxtNetAddressTypeIPv4Service, TxtNetAddressTypeIPv4Network, TxtNetAddressTypeIPv6Address, TxtNetAddressTypeIPv6AddressNoScope, TxtNetAddressTypeIPv6Service, TxtNetAddressTypeIPv6ServiceNoScope, TxtNetAddressTypeIPv6Network, TxtNetAddressTypeDNSName, TxtNetAddressTypeDNSService, TxtNetAddressTypeIPAddress, TxtNetAddressTypeIPAddressNoScope, TxtNetAddressTypeIPService, TxtNetAddressTypeIPServiceNoScope, TxtNetAddressTypeIPNetwork, TxtNetAddressTypeAnyAddress, TxtNetAddressTypeAnyAddressNoScope, TxtNetAddressTypeAnyService, TxtNetAddressTypeAnyServiceNoScope
#End If
Public Enum TxtCharacterCasingConstants
TxtCharacterCasingNormal = 0
TxtCharacterCasingUpper = 1
@wqweto
wqweto / fn_sys_GetEncodedJwt.sql
Created March 30, 2023 11:06
Encode JSON Web Token in MSSQL
IF OBJECT_ID('fn_sys_GetEncodedJwt') IS NOT NULL DROP FUNCTION fn_sys_GetEncodedJwt
GO
/*
DECLARE @Header NVARCHAR(MAX) = N'{"alg":"HS512","typ":"JWT"}', @Payload NVARCHAR(MAX) = N'{"sub":"1234567890","name":"JohnDoe","iat":1516239022}'
SELECT dbo.fn_sys_GetEncodedJwt('HS512', @Header, @Payload, CONVERT(VARBINARY(MAX), 'Password'))
*/
CREATE FUNCTION fn_sys_GetEncodedJwt (
@Algo VARCHAR(50)
, @Header NVARCHAR(MAX)
@wqweto
wqweto / mdSha3.bas
Last active February 25, 2023 17:33
[VB6/VBA] SHA-3 pure VB implementation
'--- mdSha3.bas
Option Explicit
DefObj A-Z
#Const HasPtrSafe = (VBA7 <> 0)
#Const LargeAddressAware = (Win64 = 0 And VBA7 = 0 And VBA6 = 0 And VBA5 = 0)
#Const HasOperators = (TWINBASIC <> 0)
#If HasPtrSafe Then
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
@wqweto
wqweto / mdChaCha20Poly1305.bas
Last active February 20, 2023 09:44
[VB6/VBA] Pure VB6 implementation of ChaCha20-Poly1305 authenticated encryption
'--- mdChaCha20Poly1305.bas
Option Explicit
DefObj A-Z
#Const HasPtrSafe = (VBA7 <> 0)
#Const HasOperators = (TWINBASIC <> 0)
#If HasPtrSafe Then
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
#Else
@wqweto
wqweto / mdAscon.bas
Last active February 19, 2023 21:40
[VB6/VBA] Ascon Lightweight Authenticated Encryption & Hashing
'--- mdAscon.bas
Option Explicit
DefObj A-Z
#Const HasPtrSafe = (VBA7 <> 0)
#Const HasOperators = (TWINBASIC <> 0)
#Const DebugState = False
#If HasPtrSafe Then
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
@wqweto
wqweto / stdole2.idl
Created December 21, 2022 16:16
stdole2.tlb differences win7 vs win11
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: stdole2.tlb
[
uuid(00020430-0000-0000-C000-000000000046),
version(2.0),
helpstring("OLE Automation")
]
library stdole
'--- mdSerialNumber.bas
Option Explicit
DefObj A-Z
#Const HasPtrSafe = (VBA7 <> 0) Or (TWINBASIC <> 0)
'=========================================================================
' API
'=========================================================================
@wqweto
wqweto / mdHalfSiphash.bas
Last active December 18, 2022 18:46
[VBA/VB6] SipHash cryptographically secure keyed hash function
'--- mdHalfSiphash.bas
Option Explicit
DefObj A-Z
#Const HasPtrSafe = (VBA7 <> 0)
#Const HasOperators = (TWINBASIC <> 0)
#If HasPtrSafe Then
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
Private Declare PtrSafe Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As LongPtr, ByVal cchWideChar As Long, lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long