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