private void CmdGenerate_Click(object sender, EventArgs e) { //Research // http://www.identisource.net/26_bit_format_layout.cfm // http://stackoverflow.com/questions/30919535/determine-facility-code-and-card-number-from-atr-in-c-sharp RTxtResult.Clear(); RTxtResult.AppendText(HexResult(Convert.ToInt32(TxtFacilityCode.Text), Convert.ToInt32(TxtCardCode.Text))); }
private void CmdBulkGen_Click(object sender, EventArgs e) { string[] delimiterChars = { "\r\n" }; string[] rows; rows = TxtBulkCardCode.Text.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); RTxtResult.Clear(); foreach (string s in rows) { try { RTxtResult.AppendText(HexResult(Convert.ToInt32(TxtFacilityCode.Text), Convert.ToInt32(s)) + "\r\n"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void CmdConvertHex_Click(object sender, EventArgs e) { try { //FromByteArray(hexString, int byteOffset, int bitOffset, int numberOfBits) //var cardNumber = FromByteArray(atrByteArray, 0, 1, 16); //var facilityCode = FromByteArray(atrByteArray, 0, 17, 8); RTxtResult.Clear(); var hexString = TxtConvertHex.Text; var start_number = Int64.Parse(hexString, NumberStyles.HexNumber); Int64 a_26_only = start_number & 0x3FFFFFF; //26 bits, 11 1111 1111 1111 1111 1111 1111 //Int64 result = (a_26_only >> bitOffset) & (long)(Math.Pow(2,numberOfBits)-1); RTxtResult.AppendText("Card Number:" + ((a_26_only >> 1) & (long)(Math.Pow(2, 16) - 1)).ToString() + "\r\n"); RTxtResult.AppendText("Facility Code:" + ((a_26_only >> 17) & (long)(Math.Pow(2, 8) - 1)).ToString() + "\r\n"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void CmdClear_Click(object sender, EventArgs e) { TxtBulkCardCode.Text = ""; RTxtResult.Clear(); }