473,564 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get ASCII value for character when higher than 127

Hello,

For work, I need to write a password filter. The problem is that my C+
+ experience is only some practice in school, 10 years ago. I now
develop in C# which is completely different to me.

But, the password filter needs to be built, so I'm doing my best.
First of all, I am creating an xml string that contains both username
and password, and then I want to write the ascii values for all
characters to a textfile. By using the ascii values I am sure I can
store special characters, also in a textfile.

I got it working, but only when the password only contains characters
that have an ASCII value lower than 127. But, in windows it is
possible to change a password also to something that contains special
characters, like é, ë, or €.so I also need to be able to get these
characters in my filter.

Below is the code that works for characters with ASCII values lower
than 127. Can anyone tell me what I need to do to get this working for
all characters?

I've been searching and puzzling for two days now and haven't gotten
any closer to how to solve this.

Any help will be appreciated.

Thanks in advance,
Sandra
=============== =============== =============== =============== ======

#include <windows.h>
#include <ntsecapi.h>
#include <time.h>
#include <fstream>
#include <iostream>
#include "PwdHookNew .h"
#include <sstream>
#include <string>

using namespace std;

#ifndef STATUS_SUCCESS
#define STATUS_SUCCESS ((NTSTATUS)0x00 000000L)
#endif

string GetASCIIString( string oristring)
{
unsigned char ch;

int i, j, k;
string numstrings;

ostringstream oss;

for(i=0;i<orist ring.size();i++ )
{
ch=oristring[i];
k = int(ch);

if (k<10)
{
oss << "000" << k << "-";
}
else if (k<100)
{
oss << "00" << k << "-";
}
else if(k<1000)
{
oss << "0" << k << "-";
}
else
{
oss << k << "-";
}
}
numstrings=oss. str();
oss.clear();

return numstrings;
}

NTSTATUS
NTAPI
PasswordChangeN otify(
PUNICODE_STRING UserName,
ULONG RelativeId,
PUNICODE_STRING Password
)
{
const char* timeStringForma t = "%Y-%m-%d_%H-%M-%S";
const int timeStringLengt h = 20;
char timeString[timeStringLengt h];

// get current date and time
time_t t = time(0);
tm *curTime = localtime(&t);

strftime(timeSt ring, timeStringLengt h, timeStringForma t,
curTime);

char path[80];
strcpy (path,"C:\\pwds \\");
strcat (path,timeStrin g);
strcat (path,".txt");

char *usernameStr, *passwordStr;

usernameStr = (char*)calloc(1 , (UserName->Length/2)+1);
passwordStr = (char*)calloc(1 , (Password->Length/2)+1);
wcstombs(userna meStr, UserName->Buffer, (UserName->Length/2));
wcstombs(passwo rdStr, Password->Buffer, (Password->Length/2));

char xmlmsg[150];
strcpy (xmlmsg,"<userp wd><username>") ;
strcat (xmlmsg,usernam eStr);
strcat (xmlmsg,"</username><passw ord>");
strcat (xmlmsg,passwor dStr);
strcat (xmlmsg,"</password></userpwd>");

string xmlASCII = GetASCIIString( xmlmsg);

ofstream outPwd(path, ios::app);

if (!outPwd)
{
ofstream outPwd(path, ios::out );
}

outPwd << xmlASCII ;
outPwd.close();

return STATUS_SUCCESS;
}

May 24 '07 #1
1 9298
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ss***@wxs.nl wrote:
Hello,

For work, I need to write a password filter. The problem is that my C+
+ experience is only some practice in school, 10 years ago. I now
develop in C# which is completely different to me.
Well, the comp.lang.C group doesn't have anything to do with either C++ or C#
I hope you have a C question somewhere in here.

[snip]
I got it working, but only when the password only contains characters
that have an ASCII value lower than 127.
Don't you mean that you "got it working" when the char value was between 0 and
127? FWIW, the ASCII characterset /only/ contains 7bit characters, with
values ranging from 0 to 127.

But, in windows it is
possible to change a password also to something that contains special
characters, like é, ë, or ?.so I also need to be able to get these
characters in my filter.
It appears that your system does not use the ASCII characterset. You will
first have to establish /which/ characterset your system uses, then determine
how your program can manage these characters. It may mean that you have to use
the w_char_t data type (wide characters), or you might get away with using a
straight char to hold and manipulate them.
Below is the code that works for characters with ASCII values lower
than 127. Can anyone tell me what I need to do to get this working for
all characters?
Sorry, but that /is/ the range of all ASCII characters.

I've been searching and puzzling for two days now and haven't gotten
any closer to how to solve this.

Any help will be appreciated.

Thanks in advance,
Sandra
=============== =============== =============== =============== ======

#include <windows.h>
#include <ntsecapi.h>
#include <time.h>
#include <fstream>
#include <iostream>
Bzzzzzzzttt. Wrong.

It appears that you are not writing in the C language.
Plus, you are depending on implementation-specific (not portable) facilities
and tools. I'm sorry, but you will have to take your question elsewhere - my
suggestions would be one of the comp.os.ms-windows.* newsgroups, or perhaps
comp.lang.c++

[snip]

HTH
- --
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
- ---------- Slackware - Because I know what I'm doing. ------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Armoured with GnuPG

iD8DBQFGVY+BagV FX4UWr64RAvTxAK DWDdxWGS36csYWF OJopSfYzlmj0wCg 4kra
u1nEv0YuxgjhjQb Z3gUYmKE=
=DkXy
-----END PGP SIGNATURE-----
May 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2495
by: lkrubner | last post by:
I know I'm missing something obvious, but I looked hard at this page and did not see the format of the return specified: http://us3.php.net/manual/en/function.ord.php >From the limited example I assume it is the decimal (not hex or binary) value of the character being returned? So long as the returned value is between 0 and 127, I can...
37
10130
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be accidentally entered are properly represented when the document is served. My programming language allows me to get the ascii value for any individual...
10
30122
by: Mark Rae | last post by:
Hi, I'm in the process if converting the data out of an old DOS-based SunAccounts system (don't ask!) into SQL Server. The data has been sent to me as a collection of hundreds of SunAccounts backup files and it's a simple (yet extremely laborious!) process of opening each backup file in turn, reading the file line by line, splitting it up...
1
2990
by: Kermit Piper | last post by:
Hello, I have a function that lets me convert one character and throw an alert with the corresponding ASCII value, but what I am having trouble with is applying it to a text box. What I'm trying to do is when characters are entered the function will loop through the entered values and throw an alert for each of the corresponding ASCII...
17
11774
by: Gregor Kovač | last post by:
Hi! Does DB2 handle extended ASCII table? Example: VALUES(CHR(65)) =A VALUES(CHR(129)) =null, but according to www.asciitable.com should be u with umlaut. Any idea ?
6
4068
by: ssetz | last post by:
Hello, For work, I need to write a password filter. The problem is that my C+ + experience is only some practice in school, 10 years ago. I now develop in C# which is completely different to me. But, the password filter needs to be built, so I'm doing my best. First of all, I am creating an xml string that contains both username and...
4
25048
by: meendar | last post by:
Hi, I am having a character pointer which contains ascii values. i just want to convert all these ascii values to respective characters and again store it in another character pointer. Anybody please help in c language. Thanks in Advance.
5
5425
by: tushar.saxena | last post by:
This post is a follow up to the post at : http://groups.google.com/group/comp.lang.c++/browse_thread/thread/83af6123fa945e8b?hl=ug#9eaa6fab5622424e as my original question was answered there, but I have some additional problems now. Basically what I want to do is : Given an input UTF-8 encoded file containing HTML sequences such as "&amp;", I...
9
3886
by: =?Utf-8?B?UGhhbmlkaGFy?= | last post by:
Hi, I'm developing a Winform application in C#( .net 2.0). I've a dialog box where user can input text and that text would be sent across to other machine using sockets. When the user enters ASCII character which are non-printable like ASCII 20 ( using ALT+20), this character is converted to ASCII value 194( or something like that). What...
9
4123
by: =?Utf-8?B?RGFu?= | last post by:
I have the following code section that I thought would strip out all the non-ascii characters from a string after decoding it. Unfortunately the non-ascii characters are still in the string. What am I doing wrong? Dim plainText As String plainText = "t═e" Dim plainTextBytes() As Byte Dim enc As Encoding = Encoding.ASCII...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.