Using Card Number Conversion

Card number conversion can be used for the translating of card reader output (the data the reader gets after a user swipes a card) to a card number stored in the user database (LDAP, AD, YSoft SafeQ, etc.) if these two numbers are different.

Use the Card manager editor only if you are unable to log in with a card and the Terminal access page or log files list different card numbers than your card has.

The more card number pairs you enter, the more exact results you get. You should enter at least three different pairs to get a valid result.

The Conversion Function

YSoft SafeQ 6 supports conversions of card numbers as read by the card reader at Terminal or by the LDAP replicator. If the conversion function is defined, card numbers are automatically transformed prior to matching with (or storing to) YSoft SafeQ Identity Database.

A typical conversion configuration looks as follows and is represented by the conversion attribute in the YSoft SafeQ configuration:

ASCII2Hex;Hex2Dec;Substring(-8)

Each rule is represented by its name (see the description of rules) and separated by a semicolon. Some rules have one or two parameters which are in parentheses and separated by a comma.

Substring(2);Hex2Dec;LeftPadding(0,3) + Substring(2,6);Hex2Dec

Some conversions may contain two (or more) independent conversion rules that are connected by the operator '+'.

The conversion is executed from the left, rule by rule. Each conversion rule takes the last converted number and executes. Where the operator '+' appears, it takes the output from a preceding rule, executes the rules in parallel, and returns the results of both rules. The result in the case of operator '+' may look as follows: Conversion rule: LeftPadding(0,3) + Substring(2,6) INPUT: 1a2b3c4d OUTPUT: (1a2b3c4d) + (2b3c) = 1a2b3c4d2b3c

A Description of Rules

The following rules are sorted alphabetically.

Please note that rule names are CASE SENSITIVE.

ASCII2Hex

This rule converts a string in ASCII format (typically from a KM reader) into hex form. The other input is not changed. ASCII format is "^([34][0-9])+([fF]{2})*$"
Syntax:

  • ASCII2Hex – convert only a string with a length of 32 signs

  • ASCII2Hex(length) – convert a string until a specific length
    Example:

  • ASCII2Hex(16)

  • 33303730314446383030FFFFFFFFFFFF => 30701DF800

  • 30701DF800 => 30701DF800

Bin2Dec

Converts a number from binary format into decimal format.
Syntax:

  • Bin2Dec
    Example:

  • Bin2Dec

  • 101011 => 43

Const

Returns a specified string. Could be used with the operator '+'. Similar functionality provides LeftAppend and RightAppend.
Syntax:

Dec2Bin

Converts a number from decimal format into binary format.
Syntax:

  • Dec2Bin
    Example:

  • Dec2Bin

  • 43 => 101011

Dec2Hex

Converts a number in decimal format into hexadecimal format
Syntax:

  • Dec2Hex
    Example:

  • Dex2Hex

  • 12345 => 3039

  • 123 => 7B

DecimalAdd

Adds a value in decimal format to a current value in decimal format
Syntax:

  • DecimalAdd(value)
    Example:

  • DecimalAdd(1)

  • 12345 => 12346

  • 123 => 124

DecimalAnd

Makes binary AND. Mask is in decimal format.
Syntax:

  • DecimalAnd(mask)
    Example:

  • DecimalAnd(15)

  • 7 => 7

  • 467825 => 1

DecValue2Hex

Inversion function to Hex2DecValue. Converts each pair of decimal number to a hexadecimal digit. (08 -> 8, 11 -> B). The input must have an even length.

Example:

  • 09101112 => 9ABC

  • ODD => ODD

Hex2ASCII

This is the inverse function to ASCII2Hex. Converts a hexadecimal string into an ASCII representation. The input string could have a maximum length of 16 signs. Otherwise, the original input is returned.
Syntax:

  • Hex2ASCII
    Example:

  • Hex2ASCII

  • 12AB => 31324142

  • JEDNA => JEDNA

DESDecrypt

Decodes a value encrypted by DES in Base64 format.

Example:

  • AzRapSymPps= => 1234

DESEncrypt

Encodes a value into DES and Base64 format.

Example:

  • 123 => AzRapSymPps=

Hex2ASCII

Converts a hex number to its ASCII representation. It is the inversion function to ASCII2Hex;

Example:

  • 30701DF800 => 33303730314446383030

Hex2Dec

Converts a number from hexadecimal format into decimal format.
Syntax:

  • Hex2Dec
    Example:

  • Hex2Dec

  • 12AB => 4779

Hex2DecValue

Converts each hexadecimal digit into a decimal representation (8 – 08, A – 10, B – 11, etc.).
Syntax:

  • Hex2DecValue
    Example:

  • Hex2DecValue

  • 12AB => 01021011

Hex2Oct

Converts a number from hexadecimal format into octal format.
Syntax:

  • Hex2Oct
    Example:

  • Hex2Oct

  • 12AB => 11253

HexAnd

Makes binary AND. Mask is in hexadecimal format. DecimalAnd contains similar functionality.
Syntax:

  • HexAnd(mask)
    Example:

  • HexAnd(FF)

  • 7 => 7

  • 7237B => 7B

IsEmbed

Allow next processing only if a card number is from an embedded reader.
Syntax:

  • IsEmbed
    Example:

  • IsEmbed;RightStrip(F)

  • 12345FFFFFFFFF (from embedded terminal) => 12345

  • 123F (from profi terminal) => 123F

IsEven

Allow next processing only if a card number length is even.
Syntax:

  • IsEven
    Example:

  • IsEven;LeftAppend(0)

  • 12AB => 012AB

  • 12A => 12A

IsLength

Allows next processing only if the card number length is equal to a specified value.
Syntax:

  • IsLength(value)
    Example:

  • IsLength(10);SwapPair

  • 1234567890 => 2143658709

IsLengthGreater

Allow next processing only if the card number length is greater than a specified value.
Syntax:

  • IsLengthGreater(value)
    Example:

  • IsLengthGreater(5);Substring(5)

  • 12AB => 12AB

  • 12345678 => 12345

IsLengthNot

Allow next processing only if the card number length is different to a value.
Syntax:

  • IsLengthNot(value)
    Example:

  • IsLengthNot(9);LeftAppend(0)

  • 12456789 => 123456789

  • 12345 => 012345

IsNotStartWith

Allow next processing only if the card number does not start with a specified string.
Syntax:

  • IsNotStartWith(string)
    Example:

  • IsNotStartWith(~);LeftPadding(0,8)

  • ~1234 => ~1234

  • 1234 => 00001234

IsStartWith

Allow next processing only if the card number starts with a specified string.

Syntax:

  • IsStartWith(PIN)

Example:

  • IsStartWith(PIN);Substring(3,0)

  • PIN1234 => 1234

  • 12345 => 12345

LeftAppend

Appends a specified string from the left side. RightAppend has similar functionality.
Syntax:

  • LeftAppend(prefix)
    Example:

  • LeftAppend(YSOFT-)

  • 12AB => YSOFT-12AB

LeftCut

Cuts a specified prefix from left. If the prefix does not match, then do nothing.
Syntax:

  • LeftCut(prefix)
    Example:

  • LeftCut(~1)

  • ~12AB => 2AB

  • 12A => 12A

LeftHexShift

Unary bit operation LEFT SHIFT for a specified count of bits. Input and output are in hexadecimal format. This operation is equivalent to multiplying by 2count
Syntax:

  • LeftHexShift(count)
    Example:

  • LeftHexShift(1)

  • 12AB => 2556

  • 254 => 4A8

LeftPadding

Pads with a specified sign from left to a specified length.
Syntax:

  • LeftPadding(sign,length)
    Example:

  • LeftPadding(0,10)

  • 1234ABCD => 001234ABCD

LeftShift

Unary bit operation LEFT SHIFT for a specified count of bits. Input and output are in decimal format. LeftHexShift has similar behavior. This operation is equivalent to multiplying by 2count
Syntax:

  • LeftShift(count)
    Example:

  • LeftShift(1)

  • 128 => 256

LeftStrip

Strips a specified sign from left.
Syntax:

  • LeftStrip(sign)
    Example:

  • LeftStrip(0)

  • 000012AB => 12AB

  • 00000254 => 254

LowerCase

Convert san alphabetical sign to its lowercase representation.
Syntax:

  • LowerCase
    Example:

  • LowerCase

  • CARD123 => card123

LRC

Computes a Longitudinal Redundancy Check http://en.wikipedia.org/wiki/Longitudinal_redundancy_check and adds it to the end.

Example:

  • 01044F24CC => 01044F24CCA2

MD5

Computes an MD5 hash of input.

Example:

  • 1234 => 81dc9bdb52d04dc20036dbd8313ed055

Replace

Replaces all occurrences of one sequence with another one.
Syntax:

  • Replace(source) – only removes a specified source (replace with an empty string)

  • Replace(source,dest) – replaces a specified source with dest
    Example:

  • Replace(~,0)

  • ~1234~ => 012340

  • 12~34 => 12034

Reverse2

Byte reverse – it is useful only for a hexadecimal input because 2 signs represent one byte. Therefore, this operation makes a reverse string by pair. Even the length is necessary.
Syntax:

  • Reverse2
    Example:

  • Reverse2

  • 12345678 => 78563412

Reverse

Reverse of string.
Syntax:

  • Reverse
    Example:

  • Reverse

  • 12345678 => 87654321

RightAppend

This function is similar to LeftAppend. Append a specified string from the right side.
Syntax:

  • RightAppend(suffix)
    Example:

  • RightAppend(-YSOFT)

  • 12AB => 12AB-YSOFT

RightHexShift

Unary bit operation RIGHT SHIFT for a specified count of bits. Input and output are in hexadecimal format. This operation is equivalent to dividing by 2count
Syntax:

  • RightHexShift(count)
    Example:

  • RightHexShift(1)

  • 12AB => 955

  • 254 => 12A

RightPadding

Pads with a specified sign from right to a specified length.
Syntax:

  • RightPadding(sign,length)
    Example:

  • RightPadding(F,10)

  • 1234ABCD => 1234ABCDFF

RightShift

Unary bit operation RIGHT SHIFT for a specified count of bits. Input and output are in decimal format. RightHexShift has similar behavior. This operation is equivalent to dividing by 2count
Syntax:

  • RightShift(count)
    Example:

  • RightShift(1)

  • 256 => 128

RightStrip

Strips a specified sign from the right.
Syntax:

  • RightStrip(sign)
    Example:

  • RightStrip(F)

  • 30344142FFFFFFFFFFFFFFFFF => 30344142

SignReverse

This conversion takes every string in hexadecimal format and makes its binary reverse. For example, (5 is represented in binary as 0101, reverse transfer it into 1010 that is A)
Syntax:

  • SignReverse
    Example:

  • SignReverse

  • 0123456789ABCDEF => 084C2A6E195D3B7F

Substring

Selects a substring of the input. If any argument is negative, then it is used from the right side (from the end).
Syntax:

  • Substring( n)

  • Substring(start,end)
    Example:

  • Substring(5)

  • 1234567890 => 12345

  • Substring(-5)

  • 1234567890 => 67890

  • Substring(3,0)

  • 1234567890 => 4567890

  • 123ABCDE => ABCDE

  • Substring(2,-2)

  • 1234567890 => 345678

  • 123ABCDE => 3ABC

  • Substring(-7,-2)

  • 1234567890 => 45678

  • 123ABCDE => 23ABC

Swap12785634

Swap 4th byte with 2nd. It is only useful for hexadecimal format.
Syntax:

  • Swap12785634
    Example:

  • Swap12785634

  • 12345678 => 12785634

SwapPair

Swaps even and odd signs.
Syntax:

  • SwapPair
    Example:

  • SwapPair

  • 123456 => 214365

UpperCase

Converts an alphabetical sign into its uppercase representation.
Syntax:

  • UpperCase
    Example:

  • UpperCase

  • card123 => CARD123

An Example of Usage

Importing PIN codes from a directory service – to be able to import PIN codes from a directory service such as Active Directory, it is possible to use a conversion while importing a plain text number (e.g., 1234). However, YSoft SafeQ 6, by default, expects to verify the PIN in a hash format. Therefore, the solution would be to configure "PIN code conversion" and use the following conversion: MD5;LeftAppend(PIN)