Connecting Tech Pros Worldwide Forums | Help | Site Map

String to Octet String C#

Member
 
Join Date: Mar 2007
Location: I live in a house on a street in Scarborough ON.
Posts: 95
#1: Sep 12 '08
Hi guys, I am curently working with ADAM and AZMAN and I would like to store the users passord in the ADAM database.

However it is of type Octet String. Being knew to the world of C# I have no Idea what that is and I tried to convert it t a byte array and then save it but it only errors out.

Can anyone help me with.

1. converting a textbox.text to an octet string and
2. converting an octet string value back into a string.

Thanks,
Dale.

Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#2: Sep 12 '08

re: String to Octet String C#


By octet strings, do you mean hexidecimal strings?
Expand|Select|Wrap|Line Numbers
  1. Int32 i=42;
  2. string hexstring= i.ToString("X8");
  3.  
That will give the value of 42 in hex, padded to 8 hex digits

If you have a string of characters, you will need to convert them to a byte[]. THEN, go through each byte (in a loop probably) and append that .ToString("X2") (X2 because you need to ensure that 2 hex digits come out) to another string.
I think you can do this with a StringBuilder rather nicely.
Member
 
Join Date: Mar 2007
Location: I live in a house on a street in Scarborough ON.
Posts: 95
#3: Sep 13 '08

re: String to Octet String C#


That is a good question I really don't know what an Octet string is to be honest, some say byte array bt i have tried that and the damn thing gets rejected by ADAM, if i comment it out i am able to add all the other attributes.
Reply