Sponsored Content
Full Discussion: Masking Password with *'s
Top Forums Programming Masking Password with *'s Post 302482952 by bigdrock44 on Thursday 23rd of December 2010 06:28:51 AM
Old 12-23-2010
So if I want to alter codeMaker (located in main()) with the function read_unbuffered I should not use a pointer?

Here's an excerpt from my main:
Code:
   /*Determine if code is valid*/
   valid = 0;

   while(valid != 1)
   {
      printf("Player 2, enter a secret code using values 1-6: ");

      getcode();

      /*Determine if any of the inputed coordinates are invalid*/
      for(i = 0; i < 4; i++)
      {      
         /*If invalid, warn user and re-prompt*/
         if(codeMaker[i] < 1 || codeMaker[i] > 6)     /*This codeMaker is defined in the main*/
         {
            printf("Please enter values from 1 to 6!\n\n");

            i = 4;
         }

         /*If valid AND last coordinate, continue on*/
         else if(i == 3)
         {
            valid = 1;
         }
      }
   }

And, just to refresh, here is the function:
Code:
void getcode()
{
   int ch;
   int i;
   int codeMaker[4];

   setbuf(stdin, NULL);
   echo_off();

   i = 0;

   while ((ch = getchar()) != '\n')
   {
      if(ch == '\b' && i != 0)
      {
         fprintf(stderr, "\b\b  \b\b");
         i--;
         codeMaker[i] = 0;
      }

      else if((ch >= '1') && (ch <= '6') && i < 4)
      {
         codeMaker[i] = ch - '0';
         fprintf(stderr, "* ");
         i++;
      }
   }

   printf("\n");

   echo_on();
}

As you can see, I've changed the name of read_unbuffered() to getcode(). Also in getcode() I changed the array from password[] to codeMaker[] in attempt to make this work.

So, since the codeMaker[] in getcode() is local to getcode(), it is not affecting the codeMaker[] in main(), right? Which means, when I check for validity in main() it is checking a different codeMaker[] that it needs to be checking.
 

10 More Discussions You Might Find Interesting

1. IP Networking

IP Masking

Is it possible for a internal LAN to mask a IP e.g. i have a server ip running the intranet ip being 192.168.0.8 and i want to make that like www.intranet.com is this possible on a internal network ? (1 Reply)
Discussion started by: perleo
1 Replies

2. Shell Programming and Scripting

Masking Content of a String

Hello, I need to know that whether a content of a string can be hidden or masked inside a shell script. My Sample Code is given below <Code> #!/usr/bin/ksh Userid=test DB=temp Passwd=`java Decryption test` # The Above command will get the encryped password for "test" user id and store... (2 Replies)
Discussion started by: maxmave
2 Replies

3. Shell Programming and Scripting

Data Masking

I have a pipe delimited file that I need to 'mask' to before loading to keep some data confidential. I need to maintain the first 4 bytes of certain columns and replace the remaining bytes with an 'x'. I would like to maintain spaces but it's not a requirement. Example, need to mask columns 2... (2 Replies)
Discussion started by: 1superdork
2 Replies

4. Emergency UNIX and Linux Support

Masking of number

BAT:0310:2009-08-0:Y4 :H:D:00003721:03103721.IFH:00138770:05767:00000000001279' EXR:CLP:912.570000' STA:A:9071559:2009-08-10::Wer::Mrs' DEF::531.97:531.97:310221661617::+ABC:BAL:1:N::::5:40.00:0.00:2009-08-10:CN:1111111111109962::3:N:missc :N:PH:00010833:... (5 Replies)
Discussion started by: mad_man12
5 Replies

5. Shell Programming and Scripting

Scripting help/advise on hiding/masking username/password

Hi, I currently have a UNIX script with a function that uses a username and password to connect to the database, retrieve some information and then exit. At the moment, am getting the username and password from a hidden plain text file and permission set to -r--------, i.e. read only to who... (1 Reply)
Discussion started by: newbie_01
1 Replies

6. Shell Programming and Scripting

masking issue

Hi I am facing an issue with the below script which has the below line each field being separated with a tab. I need to mask the 8 and 7th field based on following conditions 1. 8th field is 16 in length and is numerics i will mask the middle 6 digits except the first 6 and last 4. input... (2 Replies)
Discussion started by: mad_man12
2 Replies

7. Shell Programming and Scripting

Masking Password from within a Bash Shell Script

Is there a way to mask the password inside of a script to minimize the impact of a comprimised server? So ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "mysqldump --opt --all-databases -u root -pPassword| gzip" > $backup_dir/mysqldump.gz a... (2 Replies)
Discussion started by: metallica1973
2 Replies

8. Shell Programming and Scripting

Masking algorithm

I have a requirement of masking few specific fields in the UNIX file. The details are as following- File is fixed length file with each record of 250 charater length. 2 fields needs to be masked – the positions are 21:30 and 110:120 The character by character making needs to be done which... (5 Replies)
Discussion started by: n78298
5 Replies

9. UNIX for Dummies Questions & Answers

Masking data

How Can I mask one particular columns using some unix command? (4 Replies)
Discussion started by: dsa
4 Replies

10. Shell Programming and Scripting

Masking with gsub command

My file "test.dat" data as below Requirement is to mask(replace) all english characters with "X" EXCEPT first 7 characters of every line. my command awk '{gsub("]","X")}1' test.dat looks not working properly, Appreciate any suggestion... (6 Replies)
Discussion started by: JSKOBS
6 Replies
explain_getchar(3)					     Library Functions Manual						explain_getchar(3)

NAME
explain_getchar - explain getchar(3) errors SYNOPSIS
#include <libexplain/getchar.h> const char *explain_getchar(void); const char *explain_errno_getchar(int errnum, void); void explain_message_getchar(char *message, int message_size); void explain_message_errno_getchar(char *message, int message_size, int errnum); DESCRIPTION
These functions may be used to obtain explanations for errors returned by the getchar(3) system call. explain_getchar const char *explain_getchar(void); The explain_getchar function is used to obtain an explanation of an error returned by the getchar(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. The errno global variable will be used to obtain the error value to be decoded. This function is intended to be used in a fashion similar to the following example: int c = getchar(); if (c == EOF && ferror(stdin)) { fprintf(stderr, "%s ", explain_getchar()); exit(EXIT_FAILURE); } Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. explain_errno_getchar const char *explain_errno_getchar(int errnum); The explain_errno_getchar function is used to obtain an explanation of an error returned by the getchar(3) system call. The least the mes- sage will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. This function is intended to be used in a fashion similar to the following example: int c = getchar(); if (c == EOF && ferror(stdin)) { int err = errno; fprintf(stderr, "%s ", explain_errno_getchar(err, )); exit(EXIT_FAILURE); } errnum The error value to be decoded, usually obtained from the errno global variable just before this function is called. This is neces- sary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. Returns: The message explaining the error. This message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. This will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. explain_message_getchar void explain_message_getchar(char *message, int message_size); The explain_message_getchar function may be used to obtain an explanation of an error returned by the getchar(3) system call. The least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. The errno global variable will be used to obtain the error value to be decoded. This function is intended to be used in a fashion similar to the following example: int c = getchar(); if (c == EOF && ferror(stdin)) { char message[3000]; explain_message_getchar(message, sizeof(message), ); fprintf(stderr, "%s ", message); exit(EXIT_FAILURE); } message The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. message_size The size in bytes of the location in which to store the returned message. explain_message_errno_getchar void explain_message_errno_getchar(char *message, int message_size, int errnum); The explain_message_errno_getchar function may be used to obtain an explanation of an error returned by the getchar(3) system call. The least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. This function is intended to be used in a fashion similar to the following example: int c = getchar(); if (c == EOF && ferror(stdin)) { int err = errno; char message[3000]; explain_message_errno_getchar(message, sizeof(message), err, ); fprintf(stderr, "%s ", message); exit(EXIT_FAILURE); } message The location in which to store the returned message. If a suitable message return buffer is supplied, this function is thread safe. message_size The size in bytes of the location in which to store the returned message. errnum The error value to be decoded, usually obtained from the errno global variable just before this function is called. This is neces- sary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value of errno. SEE ALSO
getchar(3) input of characters explain_getchar_or_die(3) input of characters and report errors COPYRIGHT
libexplain version 0.52 Copyright (C) 2008 Peter Miller explain_getchar(3)
All times are GMT -4. The time now is 02:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy