views:

46

answers:

2

Hello All

I'm developing an application where at some point i need an encoded stream of bytes based on the given user output.

Something like

Encoding sysEncode = System.Text.Encoding.GetEncoding(850);
byte[] dataToEncrypt = sysEncode.GetBytes(m_oStrActivation);

However when i extract the string from the byte stream i get the encrypted string as

W?????e?????W?X????;??2????W???????@

Is there any way(type of Encoding/equivalent) i can restrict these question marks and allow only plain scrambled alphanumeric characters ?

+1  A: 

From m_oStrActivation and you mentioning "encryption" I assume that you're writing some kind of activation/licensing code. If this is the case, you're doing it wrong. A correct way to do this is to use a hash function over your activation data.

You can then transform this string into Base64 string using Convert.ToBase64String() method.

Anton Gogolev
To be clear for constantlearner - the `System.Text.Encoding` namespace has nothing to do with encryption - it's for dealing with character set code pages.
Michael Burr
A: 

Thanks Anton... I modified my code upon ur suggestion and i get what i need now.

@Michael, Sorry for the typo what i actually meant was Encoding when i typed Encryption

constant learner