-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create describe function for encoding an decoding #2
Comments
Not sure how displaying PIN, PAN and output can be useful. I see how pin and pan fields (that we calculate with the control char, length, padding, etc.) can be useful when you debug things e.g.:
but in the #6 , we are not showing it. We are showing only two new data points into addition to what user already has: formatted name and padding. What is the purpose of such output? I used examples from here to check if I'm doing it right. So, if our goal it to help people debug things, then I see two options for the implementation here: Option 1 - use io.Writer as a debug outputBy default, DebugOutput should be format := &formats.ISO0{
DebugOutput: os.Stdout,
} internally it can write any information that can be used for debugging - which can really be useful My concern here is the security. It would be pretty bad if someone somehow will output real pins/pans somewhere without the intention to do so. Option 2 - create methods that will show debug information so we can use them in
|
@adamdecaf what do you think about Option 1? Do you think it's ok to allow setting |
I like Option 1 and the default |
option 1 is good for me too |
Let's think about the API for this. I have following suggestions Option 1 - separate method to set debug writer + without exporting the field type ISO0 struct {
Filler string
debugOutput io.Writer
}
/// usage
pinblock := &formats.NewISO0()
pinblock.SetDebugWriter(os.Stdout) as I have a security concern, the first option seems to be a better choice. When the engineer explicitly calls a method like Option 2 - just set the field type ISO0 struct {
Filler string
DebugOutput io.Writer
}
// usage
pinblock := &formats.NewISO0()
pinblock.DebugOutput = os.Stdout it's more straightforward, but I would prefer the @mfdeveloper508 @adamdecaf what is your opinion? |
Go usually avoids setters/getters. If someone calls Option 2 is more the Go standard way of writing this. |
Like ISO8583 add the describe() function to create a human-readable output of the encoding inputs and outputs.
PIN blocks: PIN block encrypt operation finished **************************************** PAN: 43219876543210987 PIN: 1234 PAD: N/A Format: Format 0 (ISO-0) —————————————- Clear PIN block:0412AC89ABCDEF67
PIN blocks: PIN block decode operation finished **************************************** PIN block: 0412AC89ABCDEF67 PAN: 43219876543210987 PAD: N/A Format: Format 0 (ISO-0) —————————————- Decoded PIN: 1234
Support different formats of the pinblock
PIN blocks: PIN block encrypt operation finished **************************************** PAN: 432198765432109870 PIN: 1234 PAD: N/A Format: Format 4 (ISO-4) —————————————- Clear PIN block:441234AAAAAAAAAA911B9B36BC7CE94E Clear PAN block:64321987654321098700000000000000
PIN blocks: PIN block decode operation finished **************************************** PIN block: 441234AAAAAAAAAA911B9B36BC7CE94E PAN block: 64321987654321098700000000000000 PAD: N/A Format: Format 4 (ISO-4) —————————————- Decoded PIN: 1234 Decoded PAN: 432198765432109870
The text was updated successfully, but these errors were encountered: