CryptoSys API Library Manual

CNV_HexFilter

Removes non-hexadecimal characters from a string.

VB6/VBA Syntax

Public Declare Function CNV_HexFilter Lib "diCryptoSys.dll" (ByVal strOutput As String, ByVal strInput As String, ByVal nStrLen As Long) As Long

nRet = CNV_HexFilter(strOutput, strInput, nStrLen)

Parameters

strOutput
[out] String to receive filtered characters.
strInput
[in] String to be filtered.
nStrLen
[in] Long specifying the length of the input string.

C/C++ Syntax

long _stdcall CNV_HexFilter(char *output, const char *input, long len);

Returns (VB6/C)

Long: If successful, the return value is the number of characters in the filtered string; otherwise it returns a negative error code.

.NET Equivalent

Cnv.HexFilter Method

Remarks

Assumes that the output string is at least as long as the input string.

Example

Wrapper function to return a filtered string directly:

Public Function cnvHexFilter(strHex As String) As String
' Returns a string stripped of any invalid hex characters
    Dim strFiltered As String
    Dim nLen As Long
    
    strFiltered = String(Len(strHex), " ")
    nLen = CNV_HexFilter(strFiltered, strHex, Len(strHex))
    If nLen > 0 Then
        strFiltered = Left$(strFiltered, nLen)
    Else
        strFiltered = ""
    End If
    cnvHexFilter = strFiltered
End Function

See Also

CNV_HexStrFromBytes CNV_BytesFromHexStr

[Contents] [Index]

[HOME]   [NEXT: CNV_HexStrFromBytes...]

Copyright © 2001-11 D.I. Management Services Pty Ltd. All rights reserved.