473,944 Members | 2,982 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax violation error-C#-Sybase-PasswordEncrypt ion

Hi All

I'm using sybase database, I have a binary datatype column in a table, when
I'm trying to store the char(128) value into that, I'm getting syntax
violation error.

If I take "w" as the password its ascii value is 119, when you add +9 to
that, it will be 128. How to insert this value into a binary datatype
column. [ Generally when you input the ascii chars to this it will
automatically convert it to hexadecimal values and in the database you can
see only hexadecimal chars].

In a loop I'm writing this logic.
Byte[] tempBytes = Encoding.ASCII. GetBytes(UserPa ssword.Substrin g(intIndex,
1));

tempBytes = new Byte[]{Convert.ToByte ((Convert.ToInt 32(tempBytes[0]) + 9))};

strPasswd = strPasswd + Encoding.ASCII. GetString(tempB ytes);

Thanks in Advance

Karunakarraop
Nov 16 '05 #1
2 1639
Your problem has nothing to do with the database you are using. You should
post to the appropriate Sybase newsgroup for a better way to encrypt the
password (forums.sybase. com).

As for your code, try:

byte[] tempBytes = Encoding.ASCII. GetBytes(UserPa ssword);
for( int i = 0; i < tempBytes.Lengt h; i++ ) {
// Add 9 and handle overflow
tempBytes[ i ] = (byte)((tempByt es[ i ] + 9) & 255);
}
// you now have an encoded array - don't know why you want to convert it
back to a string
// but if you do, just
string newPassword = Encoding.ASCII. GetString(tempB ytes);

Again, this is a very weak way of hiding a password. Post the group
appropriate for your database to find out hold the database can do it
(encrypt) all automatically for you.

Philippe

"Karunakara rao" <ka************ @i-vantage.com> wrote in message
news:e$******** ******@TK2MSFTN GP11.phx.gbl...
Hi All

I'm using sybase database, I have a binary datatype column in a table, when I'm trying to store the char(128) value into that, I'm getting syntax
violation error.

If I take "w" as the password its ascii value is 119, when you add +9 to
that, it will be 128. How to insert this value into a binary datatype
column. [ Generally when you input the ascii chars to this it will
automatically convert it to hexadecimal values and in the database you can
see only hexadecimal chars].

In a loop I'm writing this logic.
Byte[] tempBytes = Encoding.ASCII. GetBytes(UserPa ssword.Substrin g(intIndex, 1));

tempBytes = new Byte[]{Convert.ToByte ((Convert.ToInt 32(tempBytes[0]) + 9))};
strPasswd = strPasswd + Encoding.ASCII. GetString(tempB ytes);

Thanks in Advance

Karunakarraop

Nov 16 '05 #2
Philippe Bertrand <my*****@ianywh ere.com> wrote:
Your problem has nothing to do with the database you are using. You should
post to the appropriate Sybase newsgroup for a better way to encrypt the
password (forums.sybase. com).

As for your code, try:

byte[] tempBytes = Encoding.ASCII. GetBytes(UserPa ssword);
for( int i = 0; i < tempBytes.Lengt h; i++ ) {
// Add 9 and handle overflow
tempBytes[ i ] = (byte)((tempByt es[ i ] + 9) & 255);
}


Just a couple of points:

1) Dealing with overflow is implicit in the cast to byte, unless your
code is in an unchecked context.

2) There can't be any overflow in this case, as every byte returned by
Encoding.ASCII. GetBytes is going to be in the range 0-127.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

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

Similar topics

5
3639
by: Boogie El Aceitoso | last post by:
Hi, The code below produces an access violation error, complaining that an object is destroyed twice. I don't understand why this happens. Any help would be appreciated. --------main.cpp--------------------------------------------------------------------------- #include "AbstractActivator.h"
11
4215
by: muser | last post by:
In the code I supplied before this one, the cause of the problem is an access violation error. When I run the debugger it skips into what I can only assume is the compilers version of my code. And I don't know where the problem lies in the code. Can anyone run it through there own compiler please and tell me where and what the problem is. #include <iostream> #include <iomanip> #include <fstream>
1
1866
by: Oliver | last post by:
I have a database developed fully in Access 2000 which I make available to users of both Access 97 and Access 2000. I use a split front end/back end arrangement; with the BE in Access 97. When I have made developments I reissue the front end in both A97 and A2k formats. The latest version of the front end works fine in Access 2000, however when I convert it to A97, one object (a form), results in a Dr Watson Access violation error when...
4
2274
by: Jerry | last post by:
Hi, I have an app which retrieves data from a sql server table and displays it on a datagrid. If 2 sessions of this app are running and 2 users try to update the same record at about the same time, one of the apps will yield a concurrency violation error. The app with the error will have a little red error symbol next to the record in the datagrid, and the only way I can make the error go away for now is to restart that session. Is...
2
2557
by: Agnes | last post by:
I got a simple form and using databinding manager to do the add new Now , my big trobule is . I can update the 'addnew' record, However, after I new the record, and then amend it , it got concurrency violation error, (I can solve it but I need to clear the dataset and fill in again, and I think it is not the solution) Please help -- ..
7
6264
by: Tom | last post by:
Hello all: I have a method that does a POST to a secured website using HttpWebRequest. It worked when logging in the site, but it failed with an HTTP prococol violation error when it is used to retrieve a report. Error: The underlying connection was closed: The server committed an HTTP protocol violation. I have tried to the set useUnsafeHeaderParsing to true in the app config
1
2420
by: Khadim | last post by:
I m using HTTWebResponse which is running smoothly on my system which is behing a proxy server. When I run the application with Live IP it gives "HTTP Protocol violation error" I can't use 'useUnsafeHeaderParsing' because it is not recognized by framework without sp3. I have urlencoded my data... its a simple get method with no complexity
1
1899
by: gnanapoongothai | last post by:
i have a program to calculate the CRC for a group of array values. SO i have program in a different file and i am passing the length and the array to the function and i am getting a access voilation error. couldnt understand why? plz help, here is my code crc file code #include<stdio.h> #include<windows.h> #define WIDTH 16 #define TOPBIT (1<<15)
2
2332
by: jthep | last post by:
I'm trying to get this piece of code I converted from C to work in C++ but I'm getting an access violation error. Problem occurs at line 61. Someone can help me with this? The function display(llist mylist) displays a list of choices for a record book: void display(llist mylist) { char name, address, telno, input; int yearofbirth, choice, records; yearofbirth = 0;
3
3900
by: bamsi | last post by:
Hi All, I have a typedef element defined inside the struct which i am trying to assign value using the memset and strcpy function.I am able to compile but while running it give me access violation error.Here is my code ********** #ifndef DEFINE_SAMPLETYPES #define DEFINE_SAMPLETYPES typedef char MANUFACTURER_PART_NUMBER; #endif
0
9971
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11543
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11134
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11306
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9868
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6313
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4918
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4516
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3518
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.