Click here to Skip to main content
15,910,123 members
Home / Discussions / C#
   

C#

 
Questionc# Pin
solanki12314-Sep-10 20:03
solanki12314-Sep-10 20:03 
AnswerRe: c# Pin
Dave Kreskowiak14-Sep-10 20:04
mveDave Kreskowiak14-Sep-10 20:04 
AnswerRe: c# Pin
Abhinav S14-Sep-10 20:24
Abhinav S14-Sep-10 20:24 
AnswerRe: c# Pin
Dave Kreskowiak15-Sep-10 2:12
mveDave Kreskowiak15-Sep-10 2:12 
AnswerRe: c# Pin
PIEBALDconsult15-Sep-10 3:06
mvePIEBALDconsult15-Sep-10 3:06 
Questionencoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 10:00
stephen.darling14-Sep-10 10:00 
AnswerRe: encoding and decoding in BASE 10 Pin
Ennis Ray Lynch, Jr.14-Sep-10 10:11
Ennis Ray Lynch, Jr.14-Sep-10 10:11 
AnswerRe: encoding and decoding in BASE 10 [modified] Pin
Luc Pattyn14-Sep-10 10:18
sitebuilderLuc Pattyn14-Sep-10 10:18 
Hi Steve,

1.

stephen.darling wrote:
2354 3488 3433 2332


I don't see how that would be an example. A real example would show data before and after the conversion. As it stands, it is just a data sample.

Furthermore, 4-digit numbers will not fit in a byte, as you well know. So how many bytes do you want? One per character (just replace each char by its ASCII ordinal number?).

2.
if 2354 is a string at some point, you can find the equivalent integer by calling upon int.Parse() or int.TryParse(), which I recommend.

3.
Maybe what you want is offered by the BitConverter class; have a look at GetBytes() and some of the ToInt() methods. [[FIXED]]

4.
Probably there are better schemes, that are even easier to implement.
example1: get the input string, convert it to bytes right away, then encrypt. No need to know the numeric values at all.
example2: let the user enter in the format you choose, check the format, remove all non-digits (using string.Replace), then just call long.Parse() once, to get a single 64-bit number.

5.
You seem to be struggling with some elementary C# stuff, are you sure your app needs serial numbers, encryption, and this early stage?

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.


modified on Tuesday, September 14, 2010 4:24 PM

GeneralRe: encoding and decoding in BASE 10 Pin
harold aptroot14-Sep-10 10:23
harold aptroot14-Sep-10 10:23 
GeneralRe: encoding and decoding in BASE 10 Pin
Luc Pattyn14-Sep-10 10:24
sitebuilderLuc Pattyn14-Sep-10 10:24 
AnswerRe: encoding and decoding in BASE 10 Pin
T M Gray14-Sep-10 10:21
T M Gray14-Sep-10 10:21 
GeneralRe: encoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 10:55
stephen.darling14-Sep-10 10:55 
GeneralRe: encoding and decoding in BASE 10 Pin
AspDotNetDev14-Sep-10 11:22
protectorAspDotNetDev14-Sep-10 11:22 
GeneralRe: encoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 12:11
stephen.darling14-Sep-10 12:11 
GeneralRe: encoding and decoding in BASE 10 Pin
T M Gray14-Sep-10 12:17
T M Gray14-Sep-10 12:17 
GeneralRe: encoding and decoding in BASE 10 Pin
Luc Pattyn14-Sep-10 12:28
sitebuilderLuc Pattyn14-Sep-10 12:28 
GeneralRe: encoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 12:50
stephen.darling14-Sep-10 12:50 
GeneralRe: encoding and decoding in BASE 10 [modified] Pin
Luc Pattyn14-Sep-10 13:27
sitebuilderLuc Pattyn14-Sep-10 13:27 
GeneralRe: encoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 13:36
stephen.darling14-Sep-10 13:36 
GeneralRe: encoding and decoding in BASE 10 Pin
Luc Pattyn14-Sep-10 13:43
sitebuilderLuc Pattyn14-Sep-10 13:43 
GeneralRe: encoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 14:05
stephen.darling14-Sep-10 14:05 
GeneralRe: encoding and decoding in BASE 10 Pin
AspDotNetDev14-Sep-10 14:34
protectorAspDotNetDev14-Sep-10 14:34 
GeneralRe: encoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 14:57
stephen.darling14-Sep-10 14:57 
GeneralRe: encoding and decoding in BASE 10 Pin
federico.strati15-Sep-10 3:11
federico.strati15-Sep-10 3:11 
GeneralRe: encoding and decoding in BASE 10 Pin
harold aptroot15-Sep-10 4:46
harold aptroot15-Sep-10 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.