Classic Visual Basic (VB6/VBA) code is shown shaded as follows:
Dim strData As String Dim nRet As Long strData = "Hello world" Debug.Print strData ' ... etc
Code in C/C++ is shown as:
char *str = "Hello world"; printf("%s\n", str);
Code in VB.NET is shown as:
Dim nDataLen As Integer Dim abData() As Byte If strData.Length = 0 Then Exit Function abData = System.Text.Encoding.Default.GetBytes(strData) nDataLen = abData.Length
Code in C# is shown as:
// Encrypt in CBC mode using hex strings
keyhex = "737C791F25EAD0E04629254352F7DC6291E5CB26917ADA32";
ivhex = "B36B6BFB6231084E";
plain = "5468697320736F6D652073616D706520636F6E74656E742E0808080808080808";
cipher = "d76fd1178fbd02f84231f5c1d2a2f74a4159482964f675248254223daf9af8e4";
s = Tdea.Encrypt(plain, keyhex, Mode.CBC, ivhex);
Console.WriteLine("CT={0}",s);
Console.WriteLine("OK={0}",cipher);
Debug.Assert(String.Compare(s, cipher, true)==0, "Tdea.Encrypt{Hex,CBC} failed");
Code in Python is shown as:
>>> from cryptosyspki import * >>> Gen.version() # "hello world!" for CryptoSys PKI 200600 >>> Hash.hex_from_data(b'abc') # compute SHA-1 hash in hex of 'abc' as bytes 'a9993e364706816aba3e25717850c26c9cd0d89d'
Output from code samples is shown as:
Result=OK
All functions called directly in the CryptoSys PKI Pro toolkit begin with 3 or 4 capital letters followed by an underscore "_", e.g.
nRet = RSA_ReadPublicKey(rsaReadPublicKey, nKeyLen, strKeyFile, 0)
For VBA/VB6 users, there are convenient wrapper functions provided in
basCrPKI.bas
which avoid the complications of having to pre-dimension strings, etc. These function names
begin with lowercase letters and no underscore.
For example hmacHexFromBytes
and rsaReadPublicKey
.
' Test case 1 from RFC 2202 and RFC 4231 ' Data = "Hi There" strDigest = hmacHexFromHex("4869205468657265", "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", PKI_HASH_SHA256) Debug.Print "HMAC-SHA-256=" & strDigest Debug.Print "CORRECT =b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"