代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Java
】
隐藏控制台的键盘输入
作者:
Hugh
/ 发布于
2014/1/28
/
438
using System; namespace RobvanderWoude { class HideInput { static int Main( string[] args ) { try { bool clearscreen = false; if ( args.Length > 1 ) { return WriteError( "Too many command line arguments" ); } if ( args.Length == 1 ) { switch ( args[0].ToUpper( ) ) { case "/C": clearscreen = true; break; case "/?": return WriteError( ); default: return WriteError( "Invalid command line argument \"" + args[0] + "\"" ); } } // Set console foreground color to background color to hide what's being typed ConsoleColor color = Console.ForegroundColor; Console.ForegroundColor = Console.BackgroundColor; // Read 1 line of input from the console string input = Console.ReadLine( ); // Restore the original console foreground color Console.ForegroundColor = color; // Clear the screen id specified on the command line if ( clearscreen ) { Console.Clear( ); } // Display the input - which should be redirected for this program to be of any use Console.WriteLine( input ); // Returncode 0 for success, or 1 if the input was empty or whitespace only if ( string.IsNullOrWhiteSpace( input ) ) { return 1; } else { return 0; } } catch ( Exception e ) { return WriteError( e.Message ); } } public static int WriteError( string errorMessage = "" ) { /* HideInput, Version 1.00 Batch utility to read 1 line of input while hiding what's being typed, by temporarily setting the console foreground color equal to its background color Usage: FOR /F "tokens=*" %%A IN ('HIDEINPUT') DO SET password=%%A or: FOR /F "tokens=*" %%A IN ('HIDEINPUT /C') DO SET password=%%A Where: /C clears the screen to remove what's typed from the screen buffer Written by Rob van der Woude http://www.robvanderwoude.com */ Console.ResetColor( ); if ( string.IsNullOrEmpty( errorMessage ) == false ) { Console.Error.WriteLine( ); Console.ForegroundColor = ConsoleColor.Red; Console.Error.Write( "ERROR: " ); Console.ForegroundColor = ConsoleColor.White; Console.Error.WriteLine( errorMessage ); Console.ResetColor( ); } Console.Error.WriteLine( ); Console.Error.WriteLine( "HideInput, Version 1.10" ); Console.Error.WriteLine( "Batch utility to read 1 line of input while hiding what's being typed, by" ); Console.Error.WriteLine( "temporarily setting the console foreground color equal to its background color" ); Console.Error.WriteLine( ); Console.Error.Write( "Usage: FOR /F \"tokens=*\" %%A IN ('" ); Console.ForegroundColor = ConsoleColor.White; Console.Error.Write( "HIDEINPUT" ); Console.ResetColor( ); Console.Error.WriteLine( "') DO SET password=%%A" ); Console.Error.Write( " or: FOR /F \"tokens=*\" %%A IN ('" ); Console.ForegroundColor = ConsoleColor.White; Console.Error.Write( "HIDEINPUT /C" ); Console.ResetColor( ); Console.Error.WriteLine( "') DO SET password=%%A" ); Console.Error.WriteLine( ); Console.Error.Write( "Where: " ); Console.ForegroundColor = ConsoleColor.White; Console.Error.Write( "/C" ); Console.ResetColor( ); Console.Error.WriteLine( " clears the screen to remove what's typed from the screen buffer" ); Console.Error.WriteLine( ); Console.Error.WriteLine( "Written by Rob van der Woude" ); Console.Error.WriteLine( "http://www.robvanderwoude.com" ); return 1; } } }
试试其它关键字
隐藏控制台
同语言下
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Hugh
贡献的其它代码
(
4
)
.
删除cookie的代码
.
隐藏控制台的键盘输入
.
导出数据到CVS文件
.
随机生成信用卡卡号
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3