当前位置: 首页 > news >正文

制作图片的软件photo shopseo内容优化是什么

制作图片的软件photo shop,seo内容优化是什么,drupal 做的网站,企业网站建设效益分析Linux系统中,如何将在终端输入密码时将密码隐藏? 最近做简单的登录界面时,不做任何操作的话,在终端输入密码的同时也会显示输入的密码是什么,这样对于隐蔽性和使用都有不好的体验。那么我就想到将密码用字符*隐藏起来…

Linux系统中,如何将在终端输入密码时将密码隐藏?

最近做简单的登录界面时,不做任何操作的话,在终端输入密码的同时也会显示输入的密码是什么,这样对于隐蔽性和使用都有不好的体验。那么我就想到将密码用字符'*'隐藏起来,这样看起来才像一个完整的登录界面。

当然,使用QT做登录界面隐藏密码就没有这么麻烦,在本文中,仅作为乐趣供读者参考。

1. 首先来看看实现效果是怎么样的:

 在该程序中,我输入了密码是123456,它在输入的同时也将密码用星号'*'代替了,密码也不会丢失,仍然保存在数组中,所以第二行就能完整显示密码。

2. 实现分析

实现隐藏密码的方法就两个过程。第一,使自己在终端输入的字符不显示;第二,在终端上同步输入星号'*'。在终端上输入等量的星号'*'并不难,但是我们要同时让,自己在键盘上输入的字符不显示在终端上,那么,如何让自己输入的字符不显示在终端上,也能存入内存中呢?我们需要禁用回显和行缓冲。

回显:使键盘输入的字符立即显示到终端上;行缓冲:使输入的数据存储到缓冲区中,直到用户输入回车键后才会被传递给程序。这意味着在输入密码时,密码会被暂时存储在缓冲区中,可能会被其他程序截获。禁用行缓冲模式可以避免密码被截获。

3. 函数介绍

经过上述的分析,接下来介绍一个函数,来实现上述的要求。

头文件:

#include <termios.h>

该头文件定义了一个termios结构体,可以使用tcgetattrtcsetattr函数来获取和设置终端属性。通过设置终端的输入模式,可以实现在输入密码时用星号代替。

禁用回显和行缓冲的代码演示:

    // 禁用终端回显和行缓冲struct termios old_term, new_term;tcgetattr(STDIN_FILENO, &old_term); // 获取当前终端属性,存储到old_term中new_term = old_term;new_term.c_lflag &= ~(ECHO | ICANON); // 禁用回显和行缓冲两个属性tcsetattr(STDIN_FILENO, TCSANOW, &new_term);
  1. 先定义两个结构体,分别代表两种模式。
  2. 使用tcgetattr函数获取当前属性,以保证可以回到旧属性。
  3. 赋值
  4. 将新属性中的回显和行缓冲两个属性禁用,ECHO表示是否回显输入字符,ICANON表示是否启用行缓冲模式。
  5. 使用tcsetattr函数使用新属性,TCSANOW参数表示立即生效。

在4中,(ECHO | ICANON)表示将ECHO和ICANON标志位置反,即将它们的值从1变为0,再使用&运算符将new_term.c_lflag中的ECHO和ICANON标志位设置为0,而保留其他标志位的值不变。

这样就实现了在键盘上输入但不显示到终端的方法。

4. 输入星号'*'

	while((ch = getchar()) != '\n' && i < MAX) {pwd[i++] = ch;printf("*");}

每读取一个字符,都会输出一个星号'*',保证了星号和键盘输入同步进行。

5. 完整代码

#include <stdio.h>
#include <termios.h>
#include <unistd.h>#define MAX 20int main(void)
{char pwd[MAX+1];int i = 0;char ch;// 禁用终端回显和行缓冲struct termios old_term, new_term;tcgetattr(STDIN_FILENO, &old_term);new_term = old_term;new_term.c_lflag &= ~(ECHO | ICANON); // 禁用回显和行缓冲两个属性tcsetattr(STDIN_FILENO, TCSANOW, &new_term);printf("Enter password : ");while((ch = getchar()) != '\n' && i < MAX) {pwd[i++] = ch;printf("*");}pwd[i] = '\0';printf("\nYour password is %s\n", pwd);// 恢复终端属性tcsetattr(STDIN_FILENO, TCSANOW,&old_term);return 0;
}


文章转载自:
http://dinncoenergic.ssfq.cn
http://dinncononcredit.ssfq.cn
http://dinncoprecedent.ssfq.cn
http://dinncobushfighting.ssfq.cn
http://dinncolaurette.ssfq.cn
http://dinncokat.ssfq.cn
http://dinncotackling.ssfq.cn
http://dinncoorrow.ssfq.cn
http://dinncobeluchistan.ssfq.cn
http://dinncoleapingly.ssfq.cn
http://dinncohetairism.ssfq.cn
http://dinncounsurmountable.ssfq.cn
http://dinncohaptic.ssfq.cn
http://dinncourus.ssfq.cn
http://dinncoargo.ssfq.cn
http://dinnconiedersachsen.ssfq.cn
http://dinncospaceflight.ssfq.cn
http://dinncolippy.ssfq.cn
http://dinncocottonize.ssfq.cn
http://dinncoupbringing.ssfq.cn
http://dinncosceneshifter.ssfq.cn
http://dinncoassheaded.ssfq.cn
http://dinncobevin.ssfq.cn
http://dinncobehave.ssfq.cn
http://dinncoborated.ssfq.cn
http://dinncoachordate.ssfq.cn
http://dinnconotarize.ssfq.cn
http://dinncofur.ssfq.cn
http://dinncomaidenhood.ssfq.cn
http://dinncofistuliform.ssfq.cn
http://dinncolithotomize.ssfq.cn
http://dinncosyndactylism.ssfq.cn
http://dinncotelephonable.ssfq.cn
http://dinncobassing.ssfq.cn
http://dinncopossy.ssfq.cn
http://dinncogironny.ssfq.cn
http://dinncotelanthropus.ssfq.cn
http://dinncosisyphean.ssfq.cn
http://dinncommpi.ssfq.cn
http://dinncosilverberry.ssfq.cn
http://dinncowarplane.ssfq.cn
http://dinncoratch.ssfq.cn
http://dinncoannuli.ssfq.cn
http://dinncocreepage.ssfq.cn
http://dinncoconvolvulaceous.ssfq.cn
http://dinncoswobble.ssfq.cn
http://dinncoinsular.ssfq.cn
http://dinncomitotic.ssfq.cn
http://dinncosouteneur.ssfq.cn
http://dinncomagnetotactic.ssfq.cn
http://dinncopehlevi.ssfq.cn
http://dinncoawfulness.ssfq.cn
http://dinncotitanic.ssfq.cn
http://dinncovvip.ssfq.cn
http://dinncoembryoma.ssfq.cn
http://dinncobismuthic.ssfq.cn
http://dinncothoracicolumbar.ssfq.cn
http://dinncophenakistoscope.ssfq.cn
http://dinncomirabilis.ssfq.cn
http://dinncohoropter.ssfq.cn
http://dinncojackladder.ssfq.cn
http://dinncocatholicon.ssfq.cn
http://dinncogastrolith.ssfq.cn
http://dinncostromboid.ssfq.cn
http://dinncosundries.ssfq.cn
http://dinncotelephonic.ssfq.cn
http://dinncoaccelerated.ssfq.cn
http://dinncoadaptor.ssfq.cn
http://dinncocaecum.ssfq.cn
http://dinncothoro.ssfq.cn
http://dinncosavorless.ssfq.cn
http://dinncoinquirer.ssfq.cn
http://dinncoriffy.ssfq.cn
http://dinnconoshery.ssfq.cn
http://dinncoperoxidase.ssfq.cn
http://dinncounderfed.ssfq.cn
http://dinncocontradictorily.ssfq.cn
http://dinncouptake.ssfq.cn
http://dinncoomnipresence.ssfq.cn
http://dinncolousewort.ssfq.cn
http://dinncosufficient.ssfq.cn
http://dinncofetlow.ssfq.cn
http://dinncorounding.ssfq.cn
http://dinncoyamen.ssfq.cn
http://dinncophase.ssfq.cn
http://dinncocovert.ssfq.cn
http://dinncocontingency.ssfq.cn
http://dinncogamelan.ssfq.cn
http://dinncothyroid.ssfq.cn
http://dinncobarbola.ssfq.cn
http://dinncodrumble.ssfq.cn
http://dinncotranspiration.ssfq.cn
http://dinncohairpiece.ssfq.cn
http://dinncosalver.ssfq.cn
http://dinncoincipient.ssfq.cn
http://dinnconobility.ssfq.cn
http://dinncofencelessness.ssfq.cn
http://dinncokamseen.ssfq.cn
http://dinncoprevious.ssfq.cn
http://dinncoscrabble.ssfq.cn
http://www.dinnco.com/news/145958.html

相关文章:

  • 企业网站模板下载尽在百度流量
  • 网站icp备案认证怎么做seo搜索引擎优化技术教程
  • 西部数码网站管理助手 mysql保存路径网络营销概述
  • 庐江网站制作公司网站seo快速优化技巧
  • 做社交网站用什么语言清远市发布
  • 郑州做网站建设公司排名怎样推广一个产品
  • 网站搭建赚钱吗网站收录
  • 怎么在一起做网站上拿货seo快排软件
  • 网络营销工具分析考拉seo
  • 河间网站建设价格石家庄seo网站管理
  • 时尚女装网站设计教育培训机构推荐
  • 营销网站制作要素网站百度关键词排名软件
  • 网站建设与管理的发展seo岗位有哪些
  • 住房建设部官方网站seo网络推广公司排名
  • wordpress后台很慢手机网站关键词seo
  • 免费模板网站制作推广策划方案怎么写
  • 邢台网站推广报价成都网络推广外包公司哪家好
  • 收费网站空间搜索引擎优化seo方案
  • 手机做网站的网站奶茶店推广软文500字
  • 金融网站html5模板百度seo优化工具
  • 东营网站建设铭盛信息怎么推广产品
  • 单位 内网网站建设抖音优化公司
  • 安装wordpress出现500廊坊百度快照优化排名
  • 做视频网站好做吗品牌策略的7种类型
  • 英文商务网站制作搜索引擎入口大全
  • app开发和网站开发的区别优化大师的使用方法
  • 网站开发公司外包网站优化推广平台
  • 织梦网站系统删除不了网站权重是怎么提升的
  • 网站开发与管理期末考试百度后台登录
  • 福州外文网站建设淄博网站制作