Skip to content

Instantly share code, notes, and snippets.

@xxdoc
xxdoc / mdSha2.bas
Created November 18, 2022 08:52 — forked from wqweto/mdSha2.bas
[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)
@xxdoc
xxdoc / mdArgon2.bas
Created November 18, 2022 08:50 — forked from wqweto/mdArgon2.bas
[VB6/VBA] Argon2 KDF implementation for password hashing
'--- mdArgon2.bas
Option Explicit
DefObj A-Z
#Const HasPtrSafe = (VBA7 <> 0)
#Const HasOperators = (TWINBASIC <> 0)
#Const DebugMode = False
#If HasPtrSafe Then
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
@xxdoc
xxdoc / fnc_CopyToClipWinApi.bas
Created March 8, 2022 03:38 — forked from lundeen-bryan/fnc_CopyToClipRunCmd.bas
Use win clipboard in VBA using WinAPI
Attribute VB_Name = "fnc_CopyToClipWinApi"
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function OpenClipboard Lib "User32" (ByVal hWnd As LongPtr) As LongPtr
Private Declare PtrSafe Function EmptyClipboard Lib "User32" () As LongPtr
Private Declare PtrSafe Function CloseClipboard Lib "User32" () As LongPtr
Private Declare PtrSafe Function IsClipboardFormatAvailable Lib "User32" (ByVal wFormat As LongPtr) As LongPtr
Private Declare PtrSafe Function GetClipboardData Lib "User32" (ByVal wFormat As LongPtr) As LongPtr
Private Declare PtrSafe Function SetClipboardData Lib "User32" (ByVal wFormat As LongPtr, ByVal hMem As LongPtr) As LongPtr
@xxdoc
xxdoc / fnc_CopyToClipRunCmd.bas
Created March 8, 2022 03:37
Use clipboard in VBA using RunCommand
Attribute VB_Name = "fnc_CopyToClipRunCmd"
' namespace=\
' filename=fnc_CopyToClipRunCmd.bas
Option Explicit
'' ! This WinAPI solution doesn't work see notes at EOF
Private Declare PtrSafe Function OpenClipboard Lib "user32.dll" (ByVal hWnd As LongPtr) As LongPtr
Private Declare PtrSafe Function EmptyClipboard Lib "user32.dll" () As LongPtr
Private Declare PtrSafe Function CloseClipboard Lib "user32.dll" () As LongPtr
Private Declare PtrSafe Function IsClipboardFormatAvailable Lib "user32.dll" (ByVal wFormat As LongPtr) As LongPtr
@xxdoc
xxdoc / SaveAsUTF8CSV.bas
Created March 8, 2022 03:35 — forked from whaison/SaveAsUTF8CSV.bas
SaveAsUTF8CSV.bas
Option Explicit
Sub SaveAsUTF8CSV()
'==============================
' 使用しているデータ範囲の取得
'==============================
Dim maxRow As Long
Dim maxCol As Long
@xxdoc
xxdoc / mdBlurBitmap.bas
Created October 18, 2019 07:02 — forked from wqweto/mdBlurBitmap.bas
[VB6] Blur effect on GDI+ bitmaps
Option Explicit
DefObj A-Z
'--- for VirtualProtect
Private Const PAGE_EXECUTE_READWRITE As Long = &H40
Private Const MEM_COMMIT As Long = &H1000
'--- for CryptStringToBinary
Private Const CRYPT_STRING_BASE64 As Long = 1
'--- for gdi+
Private Const ImageLockModeRead As Long = &H1
@xxdoc
xxdoc / mdMedianBlur.bas
Created October 18, 2019 06:58 — forked from wqweto/mdMedianBlur.bas
Fast O(N) median filter for GDI+ bitmaps impl w/ SSE2 thunks based on http://nomis80.org/ctmf.c
Option Explicit
DefObj A-Z
'--- for VirtualProtect
Private Const PAGE_EXECUTE_READWRITE As Long = &H40
Private Const MEM_COMMIT As Long = &H1000
'--- for CryptStringToBinary
Private Const CRYPT_STRING_BASE64 As Long = 1
'--- for GdipBitmapLockBits
Private Const ImageLockModeRead As Long = &H1
@xxdoc
xxdoc / mdCollection.bas
Created October 15, 2019 03:59 — forked from wqweto/mdCollection.bas
[VB6/VBA] Collection keys
Option Explicit
#Const HasPtrSafe = (VBA7 <> 0)
#Const LargeAddressAware = (Win64 = 0 And VBA7 = 0 And VBA6 = 0 And VBA5 = 0)
'--- for CopyMemory
#If HasPtrSafe Then
Private Const NULL_PTR As LongPtr = 0
#Else
Private Const NULL_PTR As Long = 0
@xxdoc
xxdoc / mdJson.bas
Created October 15, 2019 03:59 — forked from wqweto/mdJson.bas
JSON parsing/dumping/accessing functions
Option Explicit
DefObj A-Z
Private Const MODULE_NAME As String = "mdJson"
#Const ImplScripting = JSON_USE_SCRIPTING <> 0
#Const ImplUseShared = DebugMode <> 0
#Const HasPtrSafe = (VBA7 <> 0)
#Const LargeAddressAware = (Win64 = 0 And VBA7 = 0 And VBA6 = 0 And VBA5 = 0)
@xxdoc
xxdoc / mdPostFile.bas
Created October 15, 2019 03:58 — forked from wqweto/mdPostFile.bas
Send JSON and binary file as multipart request
Option Explicit
Private Function pvPostFile(sUrl As String, sJSON As String, sFileName As String, Optional ByVal bAsync As Boolean) As String
Const STR_BOUNDARY As String = "864d391d-4097-44e0-92e1-71aff17094c1"
Dim nFile As Integer
Dim baBuffer() As Byte
Dim sPostData As String
'--- read file
nFile = FreeFile