Skip to content

Instantly share code, notes, and snippets.

View JoshyFrancis's full-sized avatar
🏠
Working from home

Joshy Francis JoshyFrancis

🏠
Working from home
View GitHub Profile
@frdnrdb
frdnrdb / toWords.js
Created November 11, 2022 00:44
english: numbers to words/ number spelling
const AND = 'and';
const NIL = 'zero';
const NUMBERS = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
const TENS = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
const UNITS = ['', '', 'hundred', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quattuordecillion', 'quindecillion', 'sedecillion', 'septendecillion', 'octodecillion', 'novendecillion', 'vigintillion', 'unvigintillion', 'duovigintillion', 'tresvigintillion', 'quattuor­vigint­illion', 'quinvigintillion', 'sesvigintillion', 'septemvigintillion', 'octovigintillion', 'novemvigintillion', 'trigintillion', 'untrigintillion', 'duotrigintillion', 'trestrigintillion', 'quattuor­trigint­illion', 'quintrigintillion', 'sestrigintillion', 'se
@wqweto
wqweto / mdSha1.bas
Last active October 31, 2022 16:51
[VB6/VBA] Pure VB6 implementation or SHA-1 hash
'--- mdSha1.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
@wqweto
wqweto / mdBase64.bas
Last active November 18, 2022 08:52
[VB6/VBA] Simple base64 encoding and decoding by API functions
'--- mdBase64.bas
Option Explicit
DefObj A-Z
#Const HasPtrSafe = (VBA7 <> 0) Or (TWINBASIC <> 0)
#If HasPtrSafe Then
Private Declare PtrSafe Function CryptBinaryToString Lib "crypt32" Alias "CryptBinaryToStringW" (ByVal pbBinary As LongPtr, ByVal cbBinary As Long, ByVal dwFlags As Long, ByVal pszString As LongPtr, pcchString As Long) As Long
Private Declare PtrSafe Function CryptStringToBinary Lib "crypt32" Alias "CryptStringToBinaryW" (ByVal pszString As LongPtr, ByVal cchString As Long, ByVal dwFlags As Long, ByVal pbBinary As LongPtr, pcbBinary As Long, Optional ByVal pdwSkip As Long, Optional ByVal pdwFlags As Long) As Long
#Else
@wqweto
wqweto / md5.bas
Last active January 20, 2025 03:26
[VB6/VBA] Pure VB6 implementation of MD5 hash for the grins :-))
'--- md5.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
@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 / 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 / mdSha3.bas
Last active July 9, 2024 11:02
[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 / SimpleAES.cs
Last active October 27, 2022 03:35
Simple PBKDF2 based AES-256 encryption
public class SimpleAES
{
private const int SALT_SIZE = 8;
private const int KEY_SIZE = 256;
public static string Encrypt(string text, string passphrase)
{
byte[] result = null;
if (Encrypt(Encoding.UTF8.GetBytes(text), passphrase, ref result))
{
@wqweto
wqweto / mdStreamSupport.bas
Last active November 18, 2022 08:58
[VB6/VBA] IStream wrapper module
'--- mdStreamSupport.bas
Option Explicit
DefObj A-Z
#Const HasPtrSafe = (VBA7 <> 0) Or (TWINBASIC <> 0)
'=========================================================================
' API
'=========================================================================
@wqweto
wqweto / Program.cs
Created October 13, 2021 16:54
ECDSA server certificate signed by a ECDSA self-signed CA
using System;
using System.IO;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)