Jump to content

need help with coding


oracle259

Recommended Posts

[b]Token[/b]
da39a3ee5e6b4b0d3255bfef95601890afd80709
[b]Hash[/b]
d9e9cc7b89014441757996f67755c7ca1b64e188
[b]Sequence[/b]
1211121212

Say that i wanted to combine both token and hash using the above sequence where 1 represents a token character and 2 represents a hash character. eg the sequence would start as follows

dda399ae......


How do i go about accomplishing this.
Link to comment
Share on other sites

[code]<?php

$token = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
$hash = "d9e9cc7b89014441757996f67755c7ca1b64e188";
$sequence = "1211121212";

$result = "";

$i = 0;
while ($i <= (strlen($sequence)-1))
{
if($sequence{$i} == 1) $result .= $token{$i};
else $result .= $hash{$i};

$i++;
}

echo $result;

?>[/code]

Orio.
Link to comment
Share on other sites

Oh, I think I know what I mean.

I [i]think[/i] this will work.

[code]<?php

$token = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
$hash = "d9e9cc7b89014441757996f67755c7ca1b64e188";
$sequence = "1211121212";

$result = "";

$pos=0;
$num_hash=0;
$num_token=0;
$i=0;
while($i  <  ((strlen($hash)) + (strlen($token)) -1))
{
if($pos == (strlen($sequence)-1)) $pos=0;
if($sequence{$pos} == 1) {$result .= $token{$num_token}; $num_token++;}
if($sequence{$pos} == 2) {$result .= $hash{$num_hash}; $num_hash++;}
$pos++;
$i++;
}

echo $result;

?>[/code]

Orio.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.