コード例 #1
0
        static void Main(string[] args)
        {
            try
            {
                PrintHeader();

                CheckParams(args);

                Action action  = Action.Encrypt;
                string key     = string.Empty;
                string entry   = string.Empty;
                bool   reverse = false;
                foreach (string a in args)
                {
                    if (a == ENCRYPT)
                    {
                        action = Action.Encrypt;
                    }
                    else if (a == DECRYPT)
                    {
                        action = Action.Decrypt;
                    }
                    else if (a.StartsWith(KEY))
                    {
                        key = a.Substring(KEY.Length);
                    }
                    else if (a == REVERSE)
                    {
                        reverse = true;
                    }
                    else
                    {
                        entry = a;
                    }
                }

                bool   useKey = !string.IsNullOrEmpty(key);
                string result = "";
                switch (action)
                {
                case Action.Encrypt:
                    result = useKey ? CryptoImpl.Encrypt(entry, key, reverse) : CryptoImpl.Encrypt(entry, reverse);
                    break;

                case Action.Decrypt:
                    result = useKey ? CryptoImpl.Decrypt(entry, key, reverse) : CryptoImpl.Decrypt(entry, reverse);
                    break;

                default:
                    break;
                }

                Console.WriteLine(result);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Usage();
            }
        }
コード例 #2
0
        private void SetEncryptProperty(GXProperties properties, String prop)
        {
            String value = properties.Get(prop);

            if (string.IsNullOrEmpty(value))
            {
                value = "";
            }
            value = CryptoImpl.Encrypt(value);
            properties.Set(prop, value);
        }
コード例 #3
0
 private string encrypt(string value)
 {
     return(CryptoImpl.Encrypt(value, Crypto.GetServerKey()));
 }