473,378 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Base36

Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion routines? TIA

--
William Stacey, MVP
http://mvp.support.microsoft.com

Nov 16 '05 #1
15 2774
William,

this is something that i did some time ago - actually for a different base,
but it was easy enough to change to handle base32.

you did not specify the symbol set for your number base - i will assume
0,1,2,3... X,Y,Z. if yours is different, change the tokens string
accordingly.

for performance reasons, the weights of the digits are computed at compile
time.

note - there is absolutely no error checking, and it handles only positive
values, and assumes that all character codes are upper case.

regards
roy fine
namespace CONVERSION{
// handles positive only values up to 4,738,381,338,321,616,896 - 1;
public class BASE32{
static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =
{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*
36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*
36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};

public static string ToString(long lval){
int maxStrLen = powers.Length;
long curval = lval;
char [] tb = new char[maxStrLen];
int outpos = 0;
for(int i=0; i<maxStrLen; i++){
long pval = powers[maxStrLen - i - 1];
int pos = (int)(curval / pval);
tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
curval = curval % pval;
}
if(outpos==0) tb[outpos++] = '0';
return new string(tb,0,outpos).TrimStart('0');
}

public static long ToLong(string t){
long ival = 0;
char [] tb = t.ToCharArray();
for(int i=0; i<tb.Length; i++){
ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
}
return ival;
}
}
}

"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:uc****************@TK2MSFTNGP12.phx.gbl...
Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion routines? TIA
--
William Stacey, MVP
http://mvp.support.microsoft.com

Nov 16 '05 #2
Hey thanks a lot Roy. Care to post the other base as well? Either way,
thanks again!!

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:#w**************@TK2MSFTNGP09.phx.gbl...
William,

this is something that i did some time ago - actually for a different base, but it was easy enough to change to handle base32.

you did not specify the symbol set for your number base - i will assume
0,1,2,3... X,Y,Z. if yours is different, change the tokens string
accordingly.

for performance reasons, the weights of the digits are computed at compile
time.

note - there is absolutely no error checking, and it handles only positive
values, and assumes that all character codes are upper case.

regards
roy fine
namespace CONVERSION{
// handles positive only values up to 4,738,381,338,321,616,896 - 1;
public class BASE32{
static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =
{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L* 36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L* 36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L* 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};

public static string ToString(long lval){
int maxStrLen = powers.Length;
long curval = lval;
char [] tb = new char[maxStrLen];
int outpos = 0;
for(int i=0; i<maxStrLen; i++){
long pval = powers[maxStrLen - i - 1];
int pos = (int)(curval / pval);
tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
curval = curval % pval;
}
if(outpos==0) tb[outpos++] = '0';
return new string(tb,0,outpos).TrimStart('0');
}

public static long ToLong(string t){
long ival = 0;
char [] tb = t.ToCharArray();
for(int i=0; i<tb.Length; i++){
ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
}
return ival;
}
}
}

"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:uc****************@TK2MSFTNGP12.phx.gbl...
Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion routines?

TIA

--
William Stacey, MVP
http://mvp.support.microsoft.com



Nov 16 '05 #3
A generic base conversion can be applied by taking an alphabet:

private void char[] alphabet = new char[] {'0','1','2','3','4'}; // Base 5

private string IntegerToBase(int foo, char[] alphabet) {
int base = alphabet.Length;
string baseStr = "";
do {
baseStr = alphabet[foo%base] + baseStr;
foo /= base;
} while(foo > 0);

return baseStr
}

Given any alphabet, you can now go one way from integers to the base.
The reverse is more complicated, but only because certain assumptions
have to be made (converting from a well known type with specific rules
such as an integer is always easier than converting from an arbitrary type
where rules aren't self-imposed within a string).

I'm sure you also need the reverse. I already have numerous parsing
and conversion routines located in the blog space, so I'll try and elevate
this to a blog posting, and then back it with an article that contains links
and short details to all of my parsing routines to make them more
accessible.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
Hey thanks a lot Roy. Care to post the other base as well? Either way,
thanks again!!

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:#w**************@TK2MSFTNGP09.phx.gbl...
William,

this is something that i did some time ago - actually for a different

base,
but it was easy enough to change to handle base32.

you did not specify the symbol set for your number base - i will assume
0,1,2,3... X,Y,Z. if yours is different, change the tokens string
accordingly.

for performance reasons, the weights of the digits are computed at compile
time.

note - there is absolutely no error checking, and it handles only positive
values, and assumes that all character codes are upper case.

regards
roy fine
namespace CONVERSION{
// handles positive only values up to 4,738,381,338,321,616,896 - 1;
public class BASE32{
static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};

public static string ToString(long lval){
int maxStrLen = powers.Length;
long curval = lval;
char [] tb = new char[maxStrLen];
int outpos = 0;
for(int i=0; i<maxStrLen; i++){
long pval = powers[maxStrLen - i - 1];
int pos = (int)(curval / pval);
tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
curval = curval % pval;
}
if(outpos==0) tb[outpos++] = '0';
return new string(tb,0,outpos).TrimStart('0');
}

public static long ToLong(string t){
long ival = 0;
char [] tb = t.ToCharArray();
for(int i=0; i<tb.Length; i++){
ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
}
return ival;
}
}
}

"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:uc****************@TK2MSFTNGP12.phx.gbl...
> Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion routines?

TIA
>
> --
> William Stacey, MVP
> http://mvp.support.microsoft.com
>


Nov 16 '05 #4
William

The other base was base 26 and used *just* the uppercase alphabetic
characters (A..Z). The only change would be to specify the token set of the
number set and the weights of each position. For the Base26 case, it was
this:

/* ***************** */
public class BASE32{
static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =
{1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L*
26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L*
26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L*
26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
....
....
}
/* ***************** */

conversion is each direction is based on the tokens and powers arrays. the
first entry in the tokens aray always corresponds to the empty or zero
value, etc.

happy to help
roy
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
Hey thanks a lot Roy. Care to post the other base as well? Either way,
thanks again!!

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:#w**************@TK2MSFTNGP09.phx.gbl...
William,

this is something that i did some time ago - actually for a different

base,
but it was easy enough to change to handle base32.

you did not specify the symbol set for your number base - i will assume
0,1,2,3... X,Y,Z. if yours is different, change the tokens string
accordingly.

for performance reasons, the weights of the digits are computed at compile time.

note - there is absolutely no error checking, and it handles only positive values, and assumes that all character codes are upper case.

regards
roy fine
namespace CONVERSION{
// handles positive only values up to 4,738,381,338,321,616,896 - 1;
public class BASE32{
static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};

public static string ToString(long lval){
int maxStrLen = powers.Length;
long curval = lval;
char [] tb = new char[maxStrLen];
int outpos = 0;
for(int i=0; i<maxStrLen; i++){
long pval = powers[maxStrLen - i - 1];
int pos = (int)(curval / pval);
tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
curval = curval % pval;
}
if(outpos==0) tb[outpos++] = '0';
return new string(tb,0,outpos).TrimStart('0');
}

public static long ToLong(string t){
long ival = 0;
char [] tb = t.ToCharArray();
for(int i=0; i<tb.Length; i++){
ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
}
return ival;
}
}
}

"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:uc****************@TK2MSFTNGP12.phx.gbl...
Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion
routines? TIA

--
William Stacey, MVP
http://mvp.support.microsoft.com


Nov 16 '05 #5
Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2 through
base36.

The notes are extensive as to the direction the library may or may not go
depending on what
problems people are trying to solve. What I've realized is that there are a
number of additional
and interesting problems associated with alphabet encoding, such as permuations,
cyclic
rotations, error correction, and the like that may be interesting to build into
the libraries. An
example of an error correction alphabet would be the base32 encoding which
removes
characters that may be confused for other characters when read by a human.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:un**************@TK2MSFTNGP14.phx.gbl...
William

The other base was base 26 and used *just* the uppercase alphabetic
characters (A..Z). The only change would be to specify the token set of the
number set and the weights of each position. For the Base26 case, it was
this:

/* ***************** */
public class BASE32{
static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =
{1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L*
26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L*
26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L*
26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
...
...
}
/* ***************** */

conversion is each direction is based on the tokens and powers arrays. the
first entry in the tokens aray always corresponds to the empty or zero
value, etc.

happy to help
roy
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
Hey thanks a lot Roy. Care to post the other base as well? Either way,
thanks again!!

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:#w**************@TK2MSFTNGP09.phx.gbl...
> William,
>
> this is something that i did some time ago - actually for a different

base,
> but it was easy enough to change to handle base32.
>
> you did not specify the symbol set for your number base - i will assume
> 0,1,2,3... X,Y,Z. if yours is different, change the tokens string
> accordingly.
>
> for performance reasons, the weights of the digits are computed at compile > time.
>
> note - there is absolutely no error checking, and it handles only positive > values, and assumes that all character codes are upper case.
>
> regards
> roy fine
>
>
> namespace CONVERSION{
> // handles positive only values up to 4,738,381,338,321,616,896 - 1;
> public class BASE32{
> static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> static long [] powers =
>

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*
>

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*
>

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
> 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
>
> public static string ToString(long lval){
> int maxStrLen = powers.Length;
> long curval = lval;
> char [] tb = new char[maxStrLen];
> int outpos = 0;
> for(int i=0; i<maxStrLen; i++){
> long pval = powers[maxStrLen - i - 1];
> int pos = (int)(curval / pval);
> tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
> curval = curval % pval;
> }
> if(outpos==0) tb[outpos++] = '0';
> return new string(tb,0,outpos).TrimStart('0');
> }
>
> public static long ToLong(string t){
> long ival = 0;
> char [] tb = t.ToCharArray();
> for(int i=0; i<tb.Length; i++){
> ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
> }
> return ival;
> }
> }
> }
>
> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
> news:uc****************@TK2MSFTNGP12.phx.gbl...
> > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion routines? > TIA
> >
> > --
> > William Stacey, MVP
> > http://mvp.support.microsoft.com
> >
>
>


Nov 16 '05 #6
Apparentyly it whacked the link...

http://weblogs.asp.net/justin_rogers...es/253641.aspx
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2 through
base36.

The notes are extensive as to the direction the library may or may not go
depending on what
problems people are trying to solve. What I've realized is that there are a
number of additional
and interesting problems associated with alphabet encoding, such as
permuations, cyclic
rotations, error correction, and the like that may be interesting to build
into the libraries. An
example of an error correction alphabet would be the base32 encoding which
removes
characters that may be confused for other characters when read by a human.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:un**************@TK2MSFTNGP14.phx.gbl...
William

The other base was base 26 and used *just* the uppercase alphabetic
characters (A..Z). The only change would be to specify the token set of the
number set and the weights of each position. For the Base26 case, it was
this:

/* ***************** */
public class BASE32{
static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =
{1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L*
26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L*
26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L*
26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
...
...
}
/* ***************** */

conversion is each direction is based on the tokens and powers arrays. the
first entry in the tokens aray always corresponds to the empty or zero
value, etc.

happy to help
roy
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
Hey thanks a lot Roy. Care to post the other base as well? Either way,
thanks again!!

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:#w**************@TK2MSFTNGP09.phx.gbl...
> William,
>
> this is something that i did some time ago - actually for a different
base,
> but it was easy enough to change to handle base32.
>
> you did not specify the symbol set for your number base - i will assume
> 0,1,2,3... X,Y,Z. if yours is different, change the tokens string
> accordingly.
>
> for performance reasons, the weights of the digits are computed at

compile
> time.
>
> note - there is absolutely no error checking, and it handles only

positive
> values, and assumes that all character codes are upper case.
>
> regards
> roy fine
>
>
> namespace CONVERSION{
> // handles positive only values up to 4,738,381,338,321,616,896 - 1;
> public class BASE32{
> static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> static long [] powers =
>

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*
>

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*
>

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
> 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
>
> public static string ToString(long lval){
> int maxStrLen = powers.Length;
> long curval = lval;
> char [] tb = new char[maxStrLen];
> int outpos = 0;
> for(int i=0; i<maxStrLen; i++){
> long pval = powers[maxStrLen - i - 1];
> int pos = (int)(curval / pval);
> tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
> curval = curval % pval;
> }
> if(outpos==0) tb[outpos++] = '0';
> return new string(tb,0,outpos).TrimStart('0');
> }
>
> public static long ToLong(string t){
> long ival = 0;
> char [] tb = t.ToCharArray();
> for(int i=0; i<tb.Length; i++){
> ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
> }
> return ival;
> }
> }
> }
>
> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
> news:uc****************@TK2MSFTNGP12.phx.gbl...
> > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion

routines?
> TIA
> >
> > --
> > William Stacey, MVP
> > http://mvp.support.microsoft.com
> >
>
>



Nov 16 '05 #7

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
Apparentyly it whacked the link...

http://weblogs.asp.net/justin_rogers...es/253641.aspx


nice - but the code i posted works, begs for a bit of optimization, but
comes with *no* strings attached.

rlf
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2 through base36.

The notes are extensive as to the direction the library may or may not go depending on what
problems people are trying to solve. What I've realized is that there are a number of additional
and interesting problems associated with alphabet encoding, such as
permuations, cyclic
rotations, error correction, and the like that may be interesting to build into the libraries. An
example of an error correction alphabet would be the base32 encoding which removes
characters that may be confused for other characters when read by a human.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:un**************@TK2MSFTNGP14.phx.gbl...
William

The other base was base 26 and used *just* the uppercase alphabetic
characters (A..Z). The only change would be to specify the token set of the number set and the weights of each position. For the Base26 case, it was this:

/* ***************** */
public class BASE32{
static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =
{1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L* 26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L* 26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L* 26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
...
...
}
/* ***************** */

conversion is each direction is based on the tokens and powers arrays. the first entry in the tokens aray always corresponds to the empty or zero
value, etc.

happy to help
roy
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
Hey thanks a lot Roy. Care to post the other base as well? Either way, thanks again!!

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:#w**************@TK2MSFTNGP09.phx.gbl...
> William,
>
> this is something that i did some time ago - actually for a different base,
> but it was easy enough to change to handle base32.
>
> you did not specify the symbol set for your number base - i will assume > 0,1,2,3... X,Y,Z. if yours is different, change the tokens string
> accordingly.
>
> for performance reasons, the weights of the digits are computed at
compile
> time.
>
> note - there is absolutely no error checking, and it handles only
positive
> values, and assumes that all character codes are upper case.
>
> regards
> roy fine
>
>
> namespace CONVERSION{
> // handles positive only values up to 4,738,381,338,321,616,896 - 1;
> public class BASE32{
> static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> static long [] powers =
>

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L* >

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L* >

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L* > 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
>
> public static string ToString(long lval){
> int maxStrLen = powers.Length;
> long curval = lval;
> char [] tb = new char[maxStrLen];
> int outpos = 0;
> for(int i=0; i<maxStrLen; i++){
> long pval = powers[maxStrLen - i - 1];
> int pos = (int)(curval / pval);
> tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
> curval = curval % pval;
> }
> if(outpos==0) tb[outpos++] = '0';
> return new string(tb,0,outpos).TrimStart('0');
> }
>
> public static long ToLong(string t){
> long ival = 0;
> char [] tb = t.ToCharArray();
> for(int i=0; i<tb.Length; i++){
> ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
> }
> return ival;
> }
> }
> }
>
> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
> news:uc****************@TK2MSFTNGP12.phx.gbl...
> > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion
routines?
> TIA
> >
> > --
> > William Stacey, MVP
> > http://mvp.support.microsoft.com
> >
>
>



Nov 16 '05 #8
Ah, I wasn't aware alerting the author about changes to the code
that you've made is a string being attached. The licensing agreement
at the top is primarily a joke for all those that read it. It even requires
that you laugh... I put it there to reduce my own liability and to point
out that the software isn't supported. Take it for what you will.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
Apparentyly it whacked the link...

http://weblogs.asp.net/justin_rogers...es/253641.aspx


nice - but the code i posted works, begs for a bit of optimization, but
comes with *no* strings attached.

rlf
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
> Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2 through > base36.
>
> The notes are extensive as to the direction the library may or may not go > depending on what
> problems people are trying to solve. What I've realized is that there are a > number of additional
> and interesting problems associated with alphabet encoding, such as
> permuations, cyclic
> rotations, error correction, and the like that may be interesting to build > into the libraries. An
> example of an error correction alphabet would be the base32 encoding which > removes
> characters that may be confused for other characters when read by a human. >
>
> --
> Justin Rogers
> DigiTec Web Consultants, LLC.
> Blog: http://weblogs.asp.net/justin_rogers
>
> "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
> news:un**************@TK2MSFTNGP14.phx.gbl...
>> William
>>
>> The other base was base 26 and used *just* the uppercase alphabetic
>> characters (A..Z). The only change would be to specify the token set of the >> number set and the weights of each position. For the Base26 case, it was >> this:
>>
>> /* ***************** */
>> public class BASE32{
>> static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>> static long [] powers =
>> {1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L* >> 26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L* >> 26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L* >> 26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
>> ...
>> ...
>> }
>> /* ***************** */
>>
>> conversion is each direction is based on the tokens and powers arrays. the >> first entry in the tokens aray always corresponds to the empty or zero
>> value, etc.
>>
>> happy to help
>> roy
>>
>>
>> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
>> news:u$**************@TK2MSFTNGP12.phx.gbl...
>>> Hey thanks a lot Roy. Care to post the other base as well? Either way, >>> thanks again!!
>>>
>>> --
>>> William Stacey, MVP
>>> http://mvp.support.microsoft.com
>>>
>>> "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
>>> news:#w**************@TK2MSFTNGP09.phx.gbl...
>>> > William,
>>> >
>>> > this is something that i did some time ago - actually for a different >>> base,
>>> > but it was easy enough to change to handle base32.
>>> >
>>> > you did not specify the symbol set for your number base - i will assume >>> > 0,1,2,3... X,Y,Z. if yours is different, change the tokens string
>>> > accordingly.
>>> >
>>> > for performance reasons, the weights of the digits are computed at
>> compile
>>> > time.
>>> >
>>> > note - there is absolutely no error checking, and it handles only
>> positive
>>> > values, and assumes that all character codes are upper case.
>>> >
>>> > regards
>>> > roy fine
>>> >
>>> >
>>> > namespace CONVERSION{
>>> > // handles positive only values up to 4,738,381,338,321,616,896 - 1;
>>> > public class BASE32{
>>> > static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>>> > static long [] powers =
>>> >
>>>
>> {1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L* >>> >
>>>
>> 36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L* >>> >
>>>
>> 36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L* >>> > 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
>>> >
>>> > public static string ToString(long lval){
>>> > int maxStrLen = powers.Length;
>>> > long curval = lval;
>>> > char [] tb = new char[maxStrLen];
>>> > int outpos = 0;
>>> > for(int i=0; i<maxStrLen; i++){
>>> > long pval = powers[maxStrLen - i - 1];
>>> > int pos = (int)(curval / pval);
>>> > tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
>>> > curval = curval % pval;
>>> > }
>>> > if(outpos==0) tb[outpos++] = '0';
>>> > return new string(tb,0,outpos).TrimStart('0');
>>> > }
>>> >
>>> > public static long ToLong(string t){
>>> > long ival = 0;
>>> > char [] tb = t.ToCharArray();
>>> > for(int i=0; i<tb.Length; i++){
>>> > ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
>>> > }
>>> > return ival;
>>> > }
>>> > }
>>> > }
>>> >
>>> > "William Stacey [MVP]" <st***********@mvps.org> wrote in message
>>> > news:uc****************@TK2MSFTNGP12.phx.gbl...
>>> > > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion
>> routines?
>>> > TIA
>>> > >
>>> > > --
>>> > > William Stacey, MVP
>>> > > http://mvp.support.microsoft.com
>>> > >
>>> >
>>> >
>>>
>>
>>
>
>



Nov 16 '05 #9

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:eT**************@TK2MSFTNGP12.phx.gbl...
Ah, I wasn't aware alerting the author about changes to the code
that you've made is a string being attached. The licensing agreement
at the top is primarily a joke for all those that read it. It even requires that you laugh... I put it there to reduce my own liability and to point
out that the software isn't supported. Take it for what you will.

what the "recommended interpretation" of :

<quote>
The use of this software is for test and performance purposes only.

<\quote>

and

<quote>
In all seriousness,
excluding the laughter, laughter in itself does not void this license
agreement, nor compromise it's ability to legally bind you.
<\quote>

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
Apparentyly it whacked the link...

http://weblogs.asp.net/justin_rogers...es/253641.aspx


nice - but the code i posted works, begs for a bit of optimization, but
comes with *no* strings attached.

rlf
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
> Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2

through
> base36.
>
> The notes are extensive as to the direction the library may or may not
go
> depending on what
> problems people are trying to solve. What I've realized is that there

are a
> number of additional
> and interesting problems associated with alphabet encoding, such as
> permuations, cyclic
> rotations, error correction, and the like that may be interesting to

build
> into the libraries. An
> example of an error correction alphabet would be the base32 encoding

which
> removes
> characters that may be confused for other characters when read by a

human.
>
>
> --
> Justin Rogers
> DigiTec Web Consultants, LLC.
> Blog: http://weblogs.asp.net/justin_rogers
>
> "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
> news:un**************@TK2MSFTNGP14.phx.gbl...
>> William
>>
>> The other base was base 26 and used *just* the uppercase alphabetic
>> characters (A..Z). The only change would be to specify the token
set
of the
>> number set and the weights of each position. For the Base26 case,
it was
>> this:
>>
>> /* ***************** */
>> public class BASE32{
>> static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>> static long [] powers =
>>

{1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L* >>

26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L*
>>

26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L*
>> 26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
>> ...
>> ...
>> }
>> /* ***************** */
>>
>> conversion is each direction is based on the tokens and powers arrays. the
>> first entry in the tokens aray always corresponds to the empty or
zero >> value, etc.
>>
>> happy to help
>> roy
>>
>>
>> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
>> news:u$**************@TK2MSFTNGP12.phx.gbl...
>>> Hey thanks a lot Roy. Care to post the other base as well? Either

way,
>>> thanks again!!
>>>
>>> --
>>> William Stacey, MVP
>>> http://mvp.support.microsoft.com
>>>
>>> "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
>>> news:#w**************@TK2MSFTNGP09.phx.gbl...
>>> > William,
>>> >
>>> > this is something that i did some time ago - actually for a

different
>>> base,
>>> > but it was easy enough to change to handle base32.
>>> >
>>> > you did not specify the symbol set for your number base - i will

assume
>>> > 0,1,2,3... X,Y,Z. if yours is different, change the tokens string >>> > accordingly.
>>> >
>>> > for performance reasons, the weights of the digits are computed at >> compile
>>> > time.
>>> >
>>> > note - there is absolutely no error checking, and it handles only
>> positive
>>> > values, and assumes that all character codes are upper case.
>>> >
>>> > regards
>>> > roy fine
>>> >
>>> >
>>> > namespace CONVERSION{
>>> > // handles positive only values up to 4,738,381,338,321,616,896 - 1; >>> > public class BASE32{
>>> > static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>>> > static long [] powers =
>>> >
>>>
>>

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*
>>> >
>>>
>>

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*
>>> >
>>>
>>

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
>>> > 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
>>> >
>>> > public static string ToString(long lval){
>>> > int maxStrLen = powers.Length;
>>> > long curval = lval;
>>> > char [] tb = new char[maxStrLen];
>>> > int outpos = 0;
>>> > for(int i=0; i<maxStrLen; i++){
>>> > long pval = powers[maxStrLen - i - 1];
>>> > int pos = (int)(curval / pval);
>>> > tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
>>> > curval = curval % pval;
>>> > }
>>> > if(outpos==0) tb[outpos++] = '0';
>>> > return new string(tb,0,outpos).TrimStart('0');
>>> > }
>>> >
>>> > public static long ToLong(string t){
>>> > long ival = 0;
>>> > char [] tb = t.ToCharArray();
>>> > for(int i=0; i<tb.Length; i++){
>>> > ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
>>> > }
>>> > return ival;
>>> > }
>>> > }
>>> > }
>>> >
>>> > "William Stacey [MVP]" <st***********@mvps.org> wrote in message
>>> > news:uc****************@TK2MSFTNGP12.phx.gbl...
>>> > > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion
>> routines?
>>> > TIA
>>> > >
>>> > > --
>>> > > William Stacey, MVP
>>> > > http://mvp.support.microsoft.com
>>> > >
>>> >
>>> >
>>>
>>
>>
>
>



Nov 16 '05 #10
Thanks Roy. Could you expand the range by also including lower case a-z in
addition to uppercase A-Z?
If so, could you spoon feed me again with the updated logic if possible.
What I am looking to do is:
1) 5 base chars (0..9, a...z, A..Z) for count - max range up to
long.MaxRange if possible. Right now max range of ZZZZZ is 60,466,175.
2) Take a hash of count + some secret string(s) using PasswordDeriveBytes
and convert as many bytes as possible to an alpha base encoding for a max of
"HHHH-HHHH-HHHC-CCCC" (five Count positions and 11 Hash positions) to get a
Product key (e.g. MSs). I should be able to recalc the hash at the client
using stripped out count and the shared secret to verify the calculated hash
matches the hash in the Product Key supplied. May need to break the hash
bytes into two longs (16 bytes) and maybe clear high order byte before the
conversion to long so I can pass each long to the BaseXX converter to get
the string. Right now I can do 7 bytes and be sure to stay in
4738381338321616895 range.

I realize the secret is vulnerable, but think I can make it good enouph for
my needs as just an activation code. Anyway, hope above makes some sense.
Basically looking to encode bigger ranges (max longs or max ulongs, or
doubles if possible) with as few chars as possible in the valid set. Many
thanks again. Cheers.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:u7**************@tk2msftngp13.phx.gbl...

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:eT**************@TK2MSFTNGP12.phx.gbl...
Ah, I wasn't aware alerting the author about changes to the code
that you've made is a string being attached. The licensing agreement
at the top is primarily a joke for all those that read it. It even requires
that you laugh... I put it there to reduce my own liability and to point
out that the software isn't supported. Take it for what you will.


what the "recommended interpretation" of :

<quote>
The use of this software is for test and performance purposes only.

<\quote>

and

<quote>
In all seriousness,
excluding the laughter, laughter in itself does not void this license
agreement, nor compromise it's ability to legally bind you.
<\quote>

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
> Apparentyly it whacked the link...
>
> http://weblogs.asp.net/justin_rogers...es/253641.aspx
>
>

nice - but the code i posted works, begs for a bit of optimization, but comes with *no* strings attached.

rlf

> --
> Justin Rogers
> DigiTec Web Consultants, LLC.
> Blog: http://weblogs.asp.net/justin_rogers
>
>
> "Justin Rogers" <Ju****@games4dotnet.com> wrote in message
> news:Om**************@TK2MSFTNGP12.phx.gbl...
> > Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2 through
> > base36.
> >
> > The notes are extensive as to the direction the library may or may not go
> > depending on what
> > problems people are trying to solve. What I've realized is that there are a
> > number of additional
> > and interesting problems associated with alphabet encoding, such as
> > permuations, cyclic
> > rotations, error correction, and the like that may be interesting to build
> > into the libraries. An
> > example of an error correction alphabet would be the base32 encoding which
> > removes
> > characters that may be confused for other characters when read by a
human.
> >
> >
> > --
> > Justin Rogers
> > DigiTec Web Consultants, LLC.
> > Blog: http://weblogs.asp.net/justin_rogers
> >
> > "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
> > news:un**************@TK2MSFTNGP14.phx.gbl...
> >> William
> >>
> >> The other base was base 26 and used *just* the uppercase alphabetic> >> characters (A..Z). The only change would be to specify the token set of the
> >> number set and the weights of each position. For the Base26 case, it was
> >> this:
> >>
> >> /* ***************** */
> >> public class BASE32{
> >> static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> >> static long [] powers =
> >>

{1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L*
> >>

26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L*
> >>

26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L*
> >> 26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
> >> ...
> >> ...
> >> }
> >> /* ***************** */
> >>
> >> conversion is each direction is based on the tokens and powers arrays. the
> >> first entry in the tokens aray always corresponds to the empty or zero> >> value, etc.
> >>
> >> happy to help
> >> roy
> >>
> >>
> >> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
> >> news:u$**************@TK2MSFTNGP12.phx.gbl...
> >>> Hey thanks a lot Roy. Care to post the other base as well? Either way,
> >>> thanks again!!
> >>>
> >>> --
> >>> William Stacey, MVP
> >>> http://mvp.support.microsoft.com
> >>>
> >>> "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
> >>> news:#w**************@TK2MSFTNGP09.phx.gbl...
> >>> > William,
> >>> >
> >>> > this is something that i did some time ago - actually for a
different
> >>> base,
> >>> > but it was easy enough to change to handle base32.
> >>> >
> >>> > you did not specify the symbol set for your number base - i will assume
> >>> > 0,1,2,3... X,Y,Z. if yours is different, change the tokens string> >>> > accordingly.
> >>> >
> >>> > for performance reasons, the weights of the digits are computed at> >> compile
> >>> > time.
> >>> >
> >>> > note - there is absolutely no error checking, and it handles only> >> positive
> >>> > values, and assumes that all character codes are upper case.
> >>> >
> >>> > regards
> >>> > roy fine
> >>> >
> >>> >
> >>> > namespace CONVERSION{
> >>> > // handles positive only values up to 4,738,381,338,321,616,896 - 1;
> >>> > public class BASE32{
> >>> > static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> >>> > static long [] powers =
> >>> >
> >>>
> >>

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*> >>> >
> >>>
> >>

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*
> >>> >
> >>>
> >>

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
> >>> > 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
> >>> >
> >>> > public static string ToString(long lval){
> >>> > int maxStrLen = powers.Length;
> >>> > long curval = lval;
> >>> > char [] tb = new char[maxStrLen];
> >>> > int outpos = 0;
> >>> > for(int i=0; i<maxStrLen; i++){
> >>> > long pval = powers[maxStrLen - i - 1];
> >>> > int pos = (int)(curval / pval);
> >>> > tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
> >>> > curval = curval % pval;
> >>> > }
> >>> > if(outpos==0) tb[outpos++] = '0';
> >>> > return new string(tb,0,outpos).TrimStart('0');
> >>> > }
> >>> >
> >>> > public static long ToLong(string t){
> >>> > long ival = 0;
> >>> > char [] tb = t.ToCharArray();
> >>> > for(int i=0; i<tb.Length; i++){
> >>> > ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
> >>> > }
> >>> > return ival;
> >>> > }
> >>> > }
> >>> > }
> >>> >
> >>> > "William Stacey [MVP]" <st***********@mvps.org> wrote in message> >>> > news:uc****************@TK2MSFTNGP12.phx.gbl...
> >>> > > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion
> >> routines?
> >>> > TIA
> >>> > >
> >>> > > --
> >>> > > William Stacey, MVP
> >>> > > http://mvp.support.microsoft.com
> >>> > >
> >>> >
> >>> >
> >>>
> >>
> >>
> >
> >
>
>




Nov 16 '05 #11
Thanks Justin. Any chance you could add long and short support, and maybe
arbitrary byte[]s? TIA
For byte[]s I was thinking just converting each byte to base36, but that
results in 2 char min after dec 36. So maybe need to take 4 or 8 bytes at a
time and convert to int or long and convert that to a base to leverage the
resulting chars better - not sure. Any thoughts?
--
William Stacey, MVP
http://mvp.support.microsoft.com

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2 through base36.

The notes are extensive as to the direction the library may or may not go
depending on what
problems people are trying to solve. What I've realized is that there are a number of additional
and interesting problems associated with alphabet encoding, such as permuations, cyclic
rotations, error correction, and the like that may be interesting to build into the libraries. An
example of an error correction alphabet would be the base32 encoding which
removes
characters that may be confused for other characters when read by a human.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:un**************@TK2MSFTNGP14.phx.gbl...
William

The other base was base 26 and used *just* the uppercase alphabetic
characters (A..Z). The only change would be to specify the token set of the
number set and the weights of each position. For the Base26 case, it was this:

/* ***************** */
public class BASE32{
static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static long [] powers =
{1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L* 26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L* 26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L* 26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
...
...
}
/* ***************** */

conversion is each direction is based on the tokens and powers arrays. the first entry in the tokens aray always corresponds to the empty or zero
value, etc.

happy to help
roy
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:u$**************@TK2MSFTNGP12.phx.gbl...
Hey thanks a lot Roy. Care to post the other base as well? Either way, thanks again!!

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:#w**************@TK2MSFTNGP09.phx.gbl...
> William,
>
> this is something that i did some time ago - actually for a different
base,
> but it was easy enough to change to handle base32.
>
> you did not specify the symbol set for your number base - i will assume > 0,1,2,3... X,Y,Z. if yours is different, change the tokens string
> accordingly.
>
> for performance reasons, the weights of the digits are computed at

compile
> time.
>
> note - there is absolutely no error checking, and it handles only

positive
> values, and assumes that all character codes are upper case.
>
> regards
> roy fine
>
>
> namespace CONVERSION{
> // handles positive only values up to 4,738,381,338,321,616,896 - 1;
> public class BASE32{
> static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> static long [] powers =
>

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*
>

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*
>

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
> 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
>
> public static string ToString(long lval){
> int maxStrLen = powers.Length;
> long curval = lval;
> char [] tb = new char[maxStrLen];
> int outpos = 0;
> for(int i=0; i<maxStrLen; i++){
> long pval = powers[maxStrLen - i - 1];
> int pos = (int)(curval / pval);
> tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
> curval = curval % pval;
> }
> if(outpos==0) tb[outpos++] = '0';
> return new string(tb,0,outpos).TrimStart('0');
> }
>
> public static long ToLong(string t){
> long ival = 0;
> char [] tb = t.ToCharArray();
> for(int i=0; i<tb.Length; i++){
> ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
> }
> return ival;
> }
> }
> }
>
> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
> news:uc****************@TK2MSFTNGP12.phx.gbl...
> > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion

routines?
> TIA
> >
> > --
> > William Stacey, MVP
> > http://mvp.support.microsoft.com
> >
>
>




Nov 16 '05 #12
> <quote>
The use of this software is for test and performance purposes only.

<\quote>
That is to prevent users from holding me liable for putting the code
directly into a production system and having it fail. Because I don't
mention derived works (and this is from my lawyer, I figured I'd
give him a call just to make sure) you could put any derived works
into a production system.
<quote>
In all seriousness,
excluding the laughter, laughter in itself does not void this license
agreement, nor compromise it's ability to legally bind you.
<\quote>


Lawyer just laughed and noted that such jargon would not make this
any more legally binding than me walking up to you on the street and
telling you that I'd copyrighted your name and you were no longer
allowed to be called Roy. Sorry you took it out of scope.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
Nov 16 '05 #13
I'll go ahead and add some additional types. That is a a fairly easy process. I
need to put some thought into the byte array. Base64 encoding uses a special
padding character to overcome some of the issues you are noting below.

Version 1.1 is posted at the space with all of the base types added.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:OT**************@TK2MSFTNGP11.phx.gbl...
Thanks Justin. Any chance you could add long and short support, and maybe
arbitrary byte[]s? TIA
For byte[]s I was thinking just converting each byte to base36, but that
results in 2 char min after dec 36. So maybe need to take 4 or 8 bytes at a
time and convert to int or long and convert that to a base to leverage the
resulting chars better - not sure. Any thoughts?
--
William Stacey, MVP
http://mvp.support.microsoft.com

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2

through
base36.

The notes are extensive as to the direction the library may or may not go
depending on what
problems people are trying to solve. What I've realized is that there are

a
number of additional
and interesting problems associated with alphabet encoding, such as

permuations,
cyclic
rotations, error correction, and the like that may be interesting to build

into
the libraries. An
example of an error correction alphabet would be the base32 encoding which
removes
characters that may be confused for other characters when read by a human.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:un**************@TK2MSFTNGP14.phx.gbl...
> William
>
> The other base was base 26 and used *just* the uppercase alphabetic
> characters (A..Z). The only change would be to specify the token set of the > number set and the weights of each position. For the Base26 case, it was > this:
>
> /* ***************** */
> public class BASE32{
> static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
> static long [] powers =
> {1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L* > 26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L* > 26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L* > 26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
> ...
> ...
> }
> /* ***************** */
>
> conversion is each direction is based on the tokens and powers arrays. the > first entry in the tokens aray always corresponds to the empty or zero
> value, etc.
>
> happy to help
> roy
>
>
> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
> news:u$**************@TK2MSFTNGP12.phx.gbl...
>> Hey thanks a lot Roy. Care to post the other base as well? Either way, >> thanks again!!
>>
>> --
>> William Stacey, MVP
>> http://mvp.support.microsoft.com
>>
>> "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
>> news:#w**************@TK2MSFTNGP09.phx.gbl...
>> > William,
>> >
>> > this is something that i did some time ago - actually for a different
>> base,
>> > but it was easy enough to change to handle base32.
>> >
>> > you did not specify the symbol set for your number base - i will assume >> > 0,1,2,3... X,Y,Z. if yours is different, change the tokens string
>> > accordingly.
>> >
>> > for performance reasons, the weights of the digits are computed at
> compile
>> > time.
>> >
>> > note - there is absolutely no error checking, and it handles only
> positive
>> > values, and assumes that all character codes are upper case.
>> >
>> > regards
>> > roy fine
>> >
>> >
>> > namespace CONVERSION{
>> > // handles positive only values up to 4,738,381,338,321,616,896 - 1;
>> > public class BASE32{
>> > static string tokens = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>> > static long [] powers =
>> >
>>
> {1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L* >> >
>>
> 36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L* >> >
>>
> 36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L* >> > 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
>> >
>> > public static string ToString(long lval){
>> > int maxStrLen = powers.Length;
>> > long curval = lval;
>> > char [] tb = new char[maxStrLen];
>> > int outpos = 0;
>> > for(int i=0; i<maxStrLen; i++){
>> > long pval = powers[maxStrLen - i - 1];
>> > int pos = (int)(curval / pval);
>> > tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
>> > curval = curval % pval;
>> > }
>> > if(outpos==0) tb[outpos++] = '0';
>> > return new string(tb,0,outpos).TrimStart('0');
>> > }
>> >
>> > public static long ToLong(string t){
>> > long ival = 0;
>> > char [] tb = t.ToCharArray();
>> > for(int i=0; i<tb.Length; i++){
>> > ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
>> > }
>> > return ival;
>> > }
>> > }
>> > }
>> >
>> > "William Stacey [MVP]" <st***********@mvps.org> wrote in message
>> > news:uc****************@TK2MSFTNGP12.phx.gbl...
>> > > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion
> routines?
>> > TIA
>> > >
>> > > --
>> > > William Stacey, MVP
>> > > http://mvp.support.microsoft.com
>> > >
>> >
>> >
>>
>
>


Nov 16 '05 #14
William,

With your new base of 26+26+10=62, the max range for 5 digits is now 26^5 -
1, or 916,132,831.

max long is 9,223,372,036,854,775,807. Seems that what you are looking for
is 5 digits of some base that get close to max long. In other words, x^5 =
y, where y = 9,223,372,036,854,775,807.
Solving for x, we get ln(x) = ln(9,223,372,036,854,775,807) / 5, or
x = e^(ln(9,223,372,036,854,775,807) / 5),
or x = 6,208. Base 6208 is not easily representable with our standard
VT-100 vintage keyboards :(

I can find roughly 84 usable characters on my keyboard - the biggest number
that I can express in Base78 is 4,182,119,423. Here is the corresponding
code:

static string tokens =
"0123456789!@#$%^&*()_+=-<>?/.,:;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ
RSTUVWXYZ";
static long [] powers =
{1L,84L,84L*84L,84L*84L*84L,84L*84L*84L*84L,84L*84 L*84L*84L*84L,84L*84L*84L*
84L*84L*84L,84L*84L*84L*84L*84L*84L*84L,84L*84L*84 L*84L*84L*84L*84L*84L,84L*
84L*84L*84L*84L*84L*84L*84L*84L};

But - I don't think you want all those silly characters in the product key.

If you want to map 5 characters to a number in the range of
(0..long.MaxValue), consider using base 36 (0..9,A..Z) to represent a seed
value, then use that seed in a simple random number generator (of linear
congruential type). In its simplest form, the expansion could be nothing
more than:
ulong sval = x*84589UL+45989UL;

where x is the value from the 5 Base36 characters, and sval is some really
big number:

/* ***************************** */
string tstr = "ZZZZZ";
ulong x = CONVERSION.BASE.ToLong(tstr);
ulong sval = x*84589UL+45989UL;
Console.WriteLine("real big value: {0}",sval);
/* ***************************** */

As you quickly see, this is a one way mapping - i.e. not a symmetrical
process.

If you want more control over the generation - rather you want a bit more
randomness that is not as easily recognizable, consider a 28 or 32 bit
linear feedback shift register (if 32, then consider taps at 32,7,5,3,2,1
and 0). Load the value from the base 36 representation as the initial
condition, and then shift out as much precision as you need (64 shifts gives
you the range of 0..long.MaxValue).

I don't know if this helps - but it is an interesting exercise.

regards
roy fine
"William Stacey [MVP]" <st***********@mvps.org> wrote in message
news:us**************@TK2MSFTNGP14.phx.gbl...
Thanks Roy. Could you expand the range by also including lower case a-z in addition to uppercase A-Z?
If so, could you spoon feed me again with the updated logic if possible.
What I am looking to do is:
1) 5 base chars (0..9, a...z, A..Z) for count - max range up to
long.MaxRange if possible. Right now max range of ZZZZZ is 60,466,175.
2) Take a hash of count + some secret string(s) using PasswordDeriveBytes
and convert as many bytes as possible to an alpha base encoding for a max of "HHHH-HHHH-HHHC-CCCC" (five Count positions and 11 Hash positions) to get a Product key (e.g. MSs). I should be able to recalc the hash at the client
using stripped out count and the shared secret to verify the calculated hash matches the hash in the Product Key supplied. May need to break the hash
bytes into two longs (16 bytes) and maybe clear high order byte before the
conversion to long so I can pass each long to the BaseXX converter to get
the string. Right now I can do 7 bytes and be sure to stay in
4738381338321616895 range.

I realize the secret is vulnerable, but think I can make it good enouph for my needs as just an activation code. Anyway, hope above makes some sense.
Basically looking to encode bigger ranges (max longs or max ulongs, or
doubles if possible) with as few chars as possible in the valid set. Many
thanks again. Cheers.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:u7**************@tk2msftngp13.phx.gbl...

"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:eT**************@TK2MSFTNGP12.phx.gbl...
Ah, I wasn't aware alerting the author about changes to the code
that you've made is a string being attached. The licensing agreement
at the top is primarily a joke for all those that read it. It even

requires
that you laugh... I put it there to reduce my own liability and to point out that the software isn't supported. Take it for what you will.


what the "recommended interpretation" of :

<quote>
The use of this software is for test and performance purposes only.

<\quote>

and

<quote>
In all seriousness,
excluding the laughter, laughter in itself does not void this license
agreement, nor compromise it's ability to legally bind you.
<\quote>

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Roy Fine" <rl****@twt.obfuscate.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
>
> "Justin Rogers" <Ju****@games4dotnet.com> wrote in message
> news:uP**************@TK2MSFTNGP12.phx.gbl...
>> Apparentyly it whacked the link...
>>
>> http://weblogs.asp.net/justin_rogers...es/253641.aspx
>>
>>
>
> nice - but the code i posted works, begs for a bit of optimization, but > comes with *no* strings attached.
>
> rlf
>
>
>
>> --
>> Justin Rogers
>> DigiTec Web Consultants, LLC.
>> Blog: http://weblogs.asp.net/justin_rogers
>>
>>
>> "Justin Rogers" <Ju****@games4dotnet.com> wrote in message
>> news:Om**************@TK2MSFTNGP12.phx.gbl...
>> > Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2 > through
>> > base36.
>> >
>> > The notes are extensive as to the direction the library may or may
not
> go
>> > depending on what
>> > problems people are trying to solve. What I've realized is that there > are a
>> > number of additional
>> > and interesting problems associated with alphabet encoding, such
as >> > permuations, cyclic
>> > rotations, error correction, and the like that may be interesting to > build
>> > into the libraries. An
>> > example of an error correction alphabet would be the base32 encoding > which
>> > removes
>> > characters that may be confused for other characters when read by a > human.
>> >
>> >
>> > --
>> > Justin Rogers
>> > DigiTec Web Consultants, LLC.
>> > Blog: http://weblogs.asp.net/justin_rogers
>> >
>> > "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
>> > news:un**************@TK2MSFTNGP14.phx.gbl...
>> >> William
>> >>
>> >> The other base was base 26 and used *just* the uppercase alphabetic >> >> characters (A..Z). The only change would be to specify the token set
> of the
>> >> number set and the weights of each position. For the Base26
case,
it
> was
>> >> this:
>> >>
>> >> /* ***************** */
>> >> public class BASE32{
>> >> static string tokens = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>> >> static long [] powers =
>> >>
>

{1L,26L,26L*26L,26L*26L*26L,26L*26L*26L*26L,26L*26 L*26L*26L*26L,26L*26L*26L* >> >>
>

26L*26L*26L,26L*26L*26L*26L*26L*26L*26L,26L*26L*26 L*26L*26L*26L*26L*26L,26L*
>> >>
>

26L*26L*26L*26L*26L*26L*26L*26L,26L*26L*26L*26L*26 L*26L*26L*26L*26L*26L,26L*
>> >> 26L*26L*26L*26L*26L*26L*26L*26L*26L*26L};
>> >> ...
>> >> ...
>> >> }
>> >> /* ***************** */
>> >>
>> >> conversion is each direction is based on the tokens and powers

arrays.
> the
>> >> first entry in the tokens aray always corresponds to the empty or
zero
>> >> value, etc.
>> >>
>> >> happy to help
>> >> roy
>> >>
>> >>
>> >> "William Stacey [MVP]" <st***********@mvps.org> wrote in message
>> >> news:u$**************@TK2MSFTNGP12.phx.gbl...
>> >>> Hey thanks a lot Roy. Care to post the other base as well? Either > way,
>> >>> thanks again!!
>> >>>
>> >>> --
>> >>> William Stacey, MVP
>> >>> http://mvp.support.microsoft.com
>> >>>
>> >>> "Roy Fine" <rl****@twt.obfuscate.net> wrote in message
>> >>> news:#w**************@TK2MSFTNGP09.phx.gbl...
>> >>> > William,
>> >>> >
>> >>> > this is something that i did some time ago - actually for a
> different
>> >>> base,
>> >>> > but it was easy enough to change to handle base32.
>> >>> >
>> >>> > you did not specify the symbol set for your number base - i will > assume
>> >>> > 0,1,2,3... X,Y,Z. if yours is different, change the tokens

string
>> >>> > accordingly.
>> >>> >
>> >>> > for performance reasons, the weights of the digits are
computed
at
>> >> compile
>> >>> > time.
>> >>> >
>> >>> > note - there is absolutely no error checking, and it handles

only >> >> positive
>> >>> > values, and assumes that all character codes are upper case.
>> >>> >
>> >>> > regards
>> >>> > roy fine
>> >>> >
>> >>> >
>> >>> > namespace CONVERSION{
>> >>> > // handles positive only values up to 4,738,381,338,321,616,896 -
1;
>> >>> > public class BASE32{
>> >>> > static string tokens =

"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; >> >>> > static long [] powers =
>> >>> >
>> >>>
>> >>
>

{1L,36L,36L*36L,36L*36L*36L,36L*36L*36L*36L,36L*36 L*36L*36L*36L,36L*36L*36L*
>> >>> >
>> >>>
>> >>
>

36L*36L*36L,36L*36L*36L*36L*36L*36L*36L,36L*36L*36 L*36L*36L*36L*36L*36L,36L*
>> >>> >
>> >>>
>> >>
>

36L*36L*36L*36L*36L*36L*36L*36L,36L*36L*36L*36L*36 L*36L*36L*36L*36L*36L,36L*
>> >>> > 36L*36L*36L*36L*36L*36L*36L*36L*36L*36L};
>> >>> >
>> >>> > public static string ToString(long lval){
>> >>> > int maxStrLen = powers.Length;
>> >>> > long curval = lval;
>> >>> > char [] tb = new char[maxStrLen];
>> >>> > int outpos = 0;
>> >>> > for(int i=0; i<maxStrLen; i++){
>> >>> > long pval = powers[maxStrLen - i - 1];
>> >>> > int pos = (int)(curval / pval);
>> >>> > tb[outpos++] = tokens.Substring(pos,1).ToCharArray()[0];
>> >>> > curval = curval % pval;
>> >>> > }
>> >>> > if(outpos==0) tb[outpos++] = '0';
>> >>> > return new string(tb,0,outpos).TrimStart('0');
>> >>> > }
>> >>> >
>> >>> > public static long ToLong(string t){
>> >>> > long ival = 0;
>> >>> > char [] tb = t.ToCharArray();
>> >>> > for(int i=0; i<tb.Length; i++){
>> >>> > ival += powers[i]*tokens.IndexOf(tb[tb.Length-i-1]);
>> >>> > }
>> >>> > return ival;
>> >>> > }
>> >>> > }
>> >>> > }
>> >>> >
>> >>> > "William Stacey [MVP]" <st***********@mvps.org> wrote in message >> >>> > news:uc****************@TK2MSFTNGP12.phx.gbl...
>> >>> > > Anyone have a c# Base10ToBase36 and Base36ToBase10 conversion >> >> routines?
>> >>> > TIA
>> >>> > >
>> >>> > > --
>> >>> > > William Stacey, MVP
>> >>> > > http://mvp.support.microsoft.com
>> >>> > >
>> >>> >
>> >>> >
>> >>>
>> >>
>> >>
>> >
>> >
>>
>>
>
>


Nov 16 '05 #15
Lawyer just laughed and noted that such jargon would not make this
any more legally binding than me walking up to you on the street and
telling you that I'd copyrighted your name and you were no longer
allowed to be called Roy. Sorry you took it out of scope.


And I was just getting used to being called Roy... :)
Nov 16 '05 #16

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

Similar topics

4
by: Google Mike | last post by:
I have RH9 and am using the PHP and MySQL that came with it. I was doing fine with all manner of my web pages for this app until I started having this very strange problem. It's a work order...
1
by: vector | last post by:
I've got an application that generates GUIDs. A lot of GUIDs. Lots of GUIDs that end up in files on disk, taking up space. I'd like to continue using the Guid.NewGuid() function as my unique tag...
2
by: Christian H | last post by:
Hello, I was thinking of using XML based digital signatures as a licensing scheme in my application: http://www.codeproject.com/dotnet/xmldsiglic.asp As the authtor points out, the public key...
8
by: jason | last post by:
Hello everyone, I am looking for an algorithm that would take an incremental value and map that to a case-inspecific alphanumeric string. However, I don't want the string to simply step through...
4
by: Rolandas | last post by:
Hi, Can anyone help me? I need a code in VBA which would convert decimal numbers to the other system bases on number 36. e.g. in this page...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.