private void decode(CodeArg[] args)
        {
            switch (args[0].Value.ToUpper())
            {
            case (COMMAND_CODEC_TYPE_URL):
            {
                push(InstructionUtils.UrlDecode(pop()));
            }
            break;

            case (COMMAND_CODEC_TYPE_BASE64):
            {
                push(InstructionUtils.Base64Decode(pop()));
            }
            break;

            case (COMMAND_CODEC_TYPE_MD5):
            {
                throw new ArgumentException("MD5理论上不能解码,只能编码");
            }

            default:
            {
                throw new ArgumentException("不能解码这个:" + args[0].Value);
            }
            }
        }
        const string COMMAND_CODEC_TYPE_MD5    = "MD5";    //MD5编码

        private void encode(CodeArg[] args)
        {
            switch (args[0].Value.ToUpper())
            {
            case (COMMAND_CODEC_TYPE_URL):
            {
                push(InstructionUtils.UrlEncode(pop()));
            }
            break;

            case (COMMAND_CODEC_TYPE_BASE64):
            {
                push(InstructionUtils.Base64Encode(pop()));
            }
            break;

            case (COMMAND_CODEC_TYPE_MD5):
            {
                push(InstructionUtils.MD5Encrypt(pop()).ToLower());
            }
            break;

            default:
            {
                throw new ArgumentException("不能编码这个:" + args[0].Value);
            }
            }
        }
Exemple #3
0
        private void gen(CodeArg[] args)
        {
            switch (args[0].Value)
            {
            case (COMMAND_GEN_QQ):
            {
                push(InstructionUtils.RandomQQNumber());
            }
            break;

            case (COMMAND_GEN_PASSWORD):
            {
                push(InstructionUtils.RandomPassword());
            }
            break;

            case (COMMAND_GEN_TIMESTAMP):
            {
                push(InstructionUtils.GetTimestamp().ToString());
            }
            break;

            default: {
                throw new ArgumentException("不能生成这个:" + args[0].Value);
            }
            }
        }
        public void HandleRandom(StackStateMachine machine, Instruction instruction)
        {
            if (runtimeStack.Count < 1)
            {
                throw new InvalidOperationException(StackName + " 中是空的,不能随机选择");
            }
            int chosen = InstructionUtils.Rnd().Next() % runtimeStack.Count();

            push(runtimeStack[chosen]);
        }
 void GenerateTimeStamp(StackStateMachine machine, Instruction instruction)
 {
     machine.runtimeStack.Add(InstructionUtils.GetTimestamp().ToString());
 }
 void GeneratePassword(StackStateMachine machine, Instruction instruction)
 {
     machine.runtimeStack.Add(InstructionUtils.RandomPassword());
 }
 void GenerateQQ(StackStateMachine machine, Instruction instruction)
 {
     machine.runtimeStack.Add(InstructionUtils.RandomQQNumber());
 }