Syntax-wise, no there's nothing wrong with what you have there but executed
from top down you are going to have an error at b = A[2] because a is
actually a simple string by that point. (1732584193 to be exact) But I think
you are aware of that now...

I've never used BD so I'm not sure what your options are there. Can you take
a simple string, run it through your pack() and unpack() functions then post
the original string and results here?

-----Original Message-----
From: Aaron Roberson [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 10, 2006 1:50 PM
To: CF-Talk
Subject: Re: Help Converting PHP page to ColdFusion

The only use of str_pad() in this script is padding the string on the
right, so I don't need to be able to pad to the left or both.

Besides the a and A case insensitive problem, was there anything wrong
with what I did here:

A = arrayNew(1);
A[1] = 1732584193;
A[2] = 4023233417;
A[3] = 2562383102;
A[4] = 271733878;
A[5] = 3285377520;

a = A[1];
b = A[2];
c = A[3];
d = A[4];
e = A[5];

unpack() is only used once, and it is inside the cybs_sha1() function
The cybs_sha1() function is not a built in PHP function. Here is
unpack in usage:
W = array_values(unpack($fmt, $chunk));

Here is the PHP manual page for pack():
http://us2.php.net/pack

and for unpack():
http://us3.php.net/unpack

I am running BlueDragon 6.2 JX. I can't find any information about
hash() in BD so I will run a quick test and let you know.

-Aaron

On 11/10/06, Bobby Hartsfield <[EMAIL PROTECTED]> wrote:
> Ahh yes, I assumed list() created a list type. I also didn't realize this
> was all in one page so yes, a and A are going to be the same thing and the
> last one set will override the first. Just a note but it's not just
cfscript
> that is case insensitive, its all of CF.
>
> Your pad function only pads the right side of a str. The one I posted does
> left, right or both.
>
> I don't think there is a built in replacement for the list() function
though
> you could probably write a function again.
>
> Try this:
>
> <cfscript>
> A = arrayNew(1);
> A[1] = 1732584193;
> A[2] = 4023233417;
> A[3] = 2562383102;
> A[4] = 271733878;
> A[5] = 3285377520;
>
> function listvals(list, arr)
> {
>         for (i=1; i lte arraylen(arr); i = i + 1)
>         {
>                 variables[listgetat(list, i)] = arr[i];
>         }
> }
> </cfscript>
>
>
> <!--- example use of listvals() --->
> #listvals("a,b,c,d,e", A)#
> <hr />
> #a#<br />
> #b#<br />
> #c#<br />
> #d#<br />
> #e#<br />
>
>
> You say unpack() but I don't see an example of that anywhere. Did you
forget
> to post it or am I looking over it?
>
> I see pack() but the example function appears to be cybs_sha1() and THAT
> appears to be generating a sha1 hash for the given string. If that is
indeed
> what pack() does, then I'm unsure what unpack() would do since sha-1 is a
> one way hashing algorithm and the only way to 'reverse' it that I know of
is
> by bruteforce.
>
> Can you post an example of the unpack() function you are talking about?
>
> As for pack(), if it is in fact hashing strings with sha1... if you are on
> CF7, then you can use #hash("mystring", "SHA")# to hash a string in the
same
> way
>
> If you're NOT on MX7, then try this:
> http://www.cflib.org/udf.cfm?ID=34
>
> I haven't tested it but I'm assuming it works since it's still there after
5
> years. If not, CF makes it easy to import java classes and call their
> methods for use within the cf app... and there are tons of sha1 classes in
> java. One of them is bound to work :)
>
>
>
>
> -----Original Message-----
> From: Aaron Roberson [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 09, 2006 9:46 PM
> To: CF-Talk
> Subject: Re: Help Converting PHP page to ColdFusion
>
> This is what I have for str_pad:
>
> function strPad(str, length, char) // based on PadString from
> cflib.org by Rob Brooks-Bilson ([EMAIL PROTECTED])
> {
>   var pad = repeatString(char, length);
>   return str & pad;
> }
>
> This is what I did for A = array(1732584193, 4023233417, 2562383102,
> 271733878, 3285377520);
>
> A = arrayNew(1);
> A[1] = 1732584193;
> A[2] = 4023233417;
> A[3] = 2562383102;
> A[4] = 271733878;
> A[5] = 3285377520;
>
> and this for list(a,b,c,d,e)=A;
>
> a = A[1];
> b = A[2];
> c = A[3];
> d = A[4];
> e = A[5];
>
> I am concerned that I will have to go through and change all of the
> lower case "a"'s in the function to something else since CFSCRIPT is
> case-insensitive and will treat my array "A" the same as the variable
> "a".
>
> The PHP list() function doesn't just create a list as would be
> expected. Instead, it assigns each variable in the list (a,b,c,d,e) a
> value corresponding with the values in the array. that is why there is
> an equals operator after the function.
>
> I still need to figure out a replacement for the array_values() and
> unpack() PHP functions.
>
> It's coming along though, I think.
>
> -Aaron
>
> On 11/9/06, Bobby Hartsfield <[EMAIL PROTECTED]> wrote:
> > Try repeatstring() for your padding. A function shouldn't be to hard to
> > write for that though to make it easier. Here's a shot at one....
> >
> > <cfscript>
> > function str_pad (str1, str2, count, dir)
> > {
> >
> >         validDirections = "left,rigtht,r,l,both";
> >         newstr = '';
> >         if(dir is 'left' or dir is 'l')
> >         {
> >                 //pad the left
> >                 newstr = repeatstring(str2, count) & str1;
> >         }
> >         else if (dir is 'right' or dir is 'r')
> >         {
> >                 // padd the rirght
> >                 newstr = str1 & repeatstring(str2, count);
> >         }
> >         else
> >         {
> >                 //pad both sides
> >                 newstr = repeatstring(str2, count) & str1 &
> > repeatstring(str2, count);
> >         }
> >         return newstr;
> >
> > }
> > </cfscript>
> >
> > <cfoutput>
> >
> > [#str_pad ('Alien', '&nbsp;', 10, 'right')#]<br>
> > [#str_pad ('Alien', '-=', 10, 'left')#]<br>
> > [#str_pad ('Alien', '_', 10, 'both')#]<br>
> > [#str_pad ('Alien', '_', 6, 'right')#]<br>
> > <hr>
> > [Alien#repeatstring('&nbsp;', 10)#]<br>
> > [#repeatstring('-=', 10)#Alien]<br>
> > [#repeatstring('_', 10)#Alien#repeatstring('_', 10)#]<br>
> > [#repeatstring('_', 6)#Alien]<br>
> >
> > </cfoutput>
> >
> >
> >
> >
> > As for the    A = array(1732584193, 4023233417, 2562383102,  271733878,
> > 3285377520);
> >
> >
> > <cfset a = arraynew(1) />
> > <cfset a[1] = '1732584193' />
> > <cfset a[2] = '4023233417' />
> > <cfset a[3] = '2562383102' />
> > <cfset a[4] = '271733878' />
> >
> > ....would make an array with the same values
> >
> > list(a,b,c,d,e)=A;
> >
> > that would just be...
> >
> > <cfset a = "a,b,c,d,e" />
> >
> >
> >
> >
> > -----Original Message-----
> > From: Aaron Roberson [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, November 09, 2006 7:44 PM
> > To: CF-Talk
> > Subject: Re: Help Converting PHP page to ColdFusion
> >
> > Thanks Andrew, I will try your struct example.
> >
> > Do you have any ideas regarding str_pad()
> >
> > It takes three arguments, 1)the string to pad 2) the pad length and 3)
> > the padding
> >
> > What it does is pad the string on the right with the specified padding
> > at the specified length. Here is an example from the manual:
> >
> > <?php
> > $input = "Alien";
> > echo str_pad($input, 10);                      // produces "Alien    "
> > echo str_pad($input, 10, "-=", STR_PAD_LEFT);  // produces "-=-=-Alien"
> > echo str_pad($input, 10, "_", STR_PAD_BOTH);  // produces "__Alien___"
> > echo str_pad($input, 6 , "___");              // produces "Alien_"
> > ?>
> >
> > -Aaron
> >
> > On 11/9/06, Andrew Scott <[EMAIL PROTECTED]> wrote:
> > > Ok I haven't an idea of the top of my head, but you would need to loop
> > over
> > > the lsit and store in a struct
> > >
> > > or
> > >
> > > mystruct = structnew
> > > mystruct.a = listgetat(list,1);
> > > mystruct.b = listgetat(list,2);
> > > mystruct.c = listgetat(list,3);
> > >
> > > Now if you really wanted to be creative yo could create a UDF to pass
> the
> > > string and loop through and do this but natively no CF doesn't have
> this.
> > >
> > >
> > > On 11/10/06, Aaron Roberson <[EMAIL PROTECTED]> wrote:
> > > >
> > > > A = array(1732584193, 4023233417, 2562383102,  271733878,
3285377520);
> > > > list(a,b,c,d,e)=A;
> > > >
> > > > I added
> > > > A = arrayNew(1);
> > > > above this block of code.
> > > >
> > > > The first line of code is assigning the values to the array. The
> > > > second line of code uses the list() function to assing each value in
> > > > the array to the keys a,b,c,d,e so the result is this:
> > > > a = 1732584193
> > > > b = 4023233417
> > > > c = 2562383102
> > > > d = 271733878
> > > > e = 3285377520
> > > >
> > > > It should be simple to do in ColdFusion but I can't think of the
> > solution.
> > > >
> > > > -Aaron
> > > >
> > > > On 11/9/06, Andrew Scott <[EMAIL PROTECTED]> wrote:
> > > > > Aaron not to be able to answer all your questions but a constant
is
> a
> > > > > variable that does not change hence why they call it a constant
> > > > variable.
> > > > >
> > > > > So in answer to you there
> > > > >
> > > > > <cfif isDefined('Varaible') />
> > > > >
> > > > > Would check for the existance of that variable, the other way is
> > > > >
> > > > > <cfparam name="Variable" default="hello" />
> > > > >
> > > > > This would also check the existance of a variable, but it will
> assign
> > it
> > > > a
> > > > > default value as well.
> > > > >
> > > > > Now I am sure cyba_sha1 is a MD5 hashing encryption so you might
> look
> > at
> > > > the
> > > > > function has on coldfusion.
> > > > >
> > > > > Not sure what this does
> > > > > A = array(1732584193, 4023233417, 2562383102,  271733878,
> 3285377520);
> > > > > list(a,b,c,d,e)=A; so can't answer you there.
> > > > >
> > > > > and strpad you might go to udf.com I think it is  for string
> > > > manipulation
> > > > > code.
> > > >
> > > >
> > >
> > >
> >
> >
> >
> >
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259940
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to