Beispiel #1
0
        private static ExitCode RunEncodeOptionsAndReturnExitCode(EncodeOptions encodeOptions)
        {
            string encodedString = null;
            string errorMsg      = null;

            switch (encodeOptions.EncodeType.ToLower())
            {
            case "base64":
            {
                encodedString = Base64.ToBase64String(encodeOptions.InputToEncode);
            }
            break;

            case "hex":
            {
                encodedString = Hexadecimal.ToHexString(encodeOptions.InputToEncode);
            }
            break;

            default:
                errorMsg = $"Unknown encode type \"{encodeOptions.EncodeType}\".";
                break;
            }

            if (string.IsNullOrWhiteSpace(errorMsg))
            {
                Console.WriteLine(encodedString);

                return(ExitCode.Sucess);
            }
            else
            {
                Console.WriteLine(errorMsg);

                return(ExitCode.Error);
            }
        }