Skip to main content

decoder-decode-data

// Use MKE Decoder created in previous example

// Initialize MteStatus
MteStatus decoderStatus;

// Below are 4 different examples of how to decode
// ONLY ONE needs to be used.
// Decode byte[] to a base64 string
string decodedBytesAsString = mkeDecoder.DecodeStr(encodedBytes, out decoderStatus);
if (mkeDecoder.StatusIsError(decoderStatus)) {
// Unable to decode, this checks for errors, handle failure appropriately
// Below is only an example
Console.Error.WriteLine("Decode error ({0}): {1}",
mkeDecoder.GetStatusName(decoderStatus),
mkeDecoder.GetStatusDescription(decoderStatus));
return (int)status;
// This catches Decoder warnings, the decode process was successful
// But depending on the type of security needed these may be ignored
// Please see Developer Guide for more details.
} else if (status != MteStatus.mte_status_success) {
Console.Error.WriteLine("Decode warning ({0}): {1}",
mkeDecoder.GetStatusName(decoderStatus),
mkeDecoder.GetStatusDescription(decoderStatus));
}
// Decode string to a base64 string
string decodedStringAsString = mkeDecoder.DecodeStrB64(encodedBase64String, out decoderStatus);
if (mkeDecoder.StatusIsError(decoderStatus)) {
// Unable to decode, this checks for errors, handle failure appropriately
// Below is only an example
Console.Error.WriteLine("Decode error ({0}): {1}",
mkeDecoder.GetStatusName(decoderStatus),
mkeDecoder.GetStatusDescription(decoderStatus));
return (int)status;
// This catches Decoder warnings, the decode process was successful
// But depending on the type of security needed these may be ignored
// Please see Developer Guide for more details.
} else if (status != MteStatus.mte_status_success) {
Console.Error.WriteLine("Decode warning ({0}): {1}",
mkeDecoder.GetStatusName(decoderStatus),
mkeDecoder.GetStatusDescription(decoderStatus));
}
// Decode byte[] to a byte[]
byte[] decodedBytes = mkeDecoder.Decode(encodedBytes, out decoderStatus);
if (mkeDecoder.StatusIsError(decoderStatus)) {
// Unable to decode, this checks for errors, handle failure appropriately
// Below is only an example
Console.Error.WriteLine("Decode error ({0}): {1}",
mkeDecoder.GetStatusName(decoderStatus),
mkeDecoder.GetStatusDescription(decoderStatus));
return (int)status;
// This catches Decoder warnings, the decode process was successful
// But depending on the type of security needed these may be ignored
// Please see Developer Guide for more details.
} else if (status != MteStatus.mte_status_success) {
Console.Error.WriteLine("Decode warning ({0}): {1}",
mkeDecoder.GetStatusName(decoderStatus),
mkeDecoder.GetStatusDescription(decoderStatus));
}
// Decode string to a byte[]
byte[] decodedStringAsBytes = mkeDecoder.DecodeB64(encodedBase64String, out decoderStatus);
if (mkeDecoder.StatusIsError(decoderStatus)) {
// Unable to decode, this checks for errors, handle failure appropriately
// Below is only an example
Console.Error.WriteLine("Decode error ({0}): {1}",
mkeDecoder.GetStatusName(decoderStatus),
mkeDecoder.GetStatusDescription(decoderStatus));
return (int)status;
// This catches Decoder warnings, the decode process was successful
// But depending on the type of security needed these may be ignored
// Please see Developer Guide for more details.
} else if (status != MteStatus.mte_status_success) {
Console.Error.WriteLine("Decode warning ({0}): {1}",
mkeDecoder.GetStatusName(decoderStatus),
mkeDecoder.GetStatusDescription(decoderStatus));
}