没有回显输入密码实现

InputPassword.exe

注意:

为避免64位操作系统出现错误,做以下设置:

1.MFC的使用:选择“在静态库中使用MFC”

2.配置属性——》C/C++——》常规——》检测64位可移植性问题——》是

#include <stdio.h>
#include <string.h>
#include <conio.h>

#define MAX_PWD_LEN 32

void GetPassword(char * pwd)
{
	int i = 0;
	char c;

	while ((c=getch()) != '\r')
	{
		if (i >= MAX_PWD_LEN-1)
		{
			break;
		}

		pwd[i] = c;
		++i;
	}
}

int main(void)
{
	char pwd[MAX_PWD_LEN];
	memset(pwd, 0, MAX_PWD_LEN);
	
	GetPassword(pwd);
	printf_s("%s", pwd);

	return 0;
}

bat脚本:
@echo off

echo input the password of sa :

set /p sapwd=input the sapwd :

echo %sapwd%>>log.txt

echo %sapwd%|findstr "^[a-z0-9A-Z_]*$" 1>nul 2>nul
if not %errorlevel%==0 (
    echo "the sapwd you input is invalid."
)

for /f "delims=" %%i in ('InputPassword.exe') do (  
 set sapwd=%%i  
)  
echo %sapwd% >>log.txt

echo %sapwd%|findstr "^[a-z0-9A-Z_]*$" 1>nul 2>nul
if not %errorlevel%==0 (
    echo "the sapwd you input is invalid."
)

pause


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值