droopz17 Posted June 26, 2007 Share Posted June 26, 2007 I have searched far and low for a way to encode my cookies and then decode them. I can't find crap. So i'm curious if a function like the one i wrote real quick below would work at all, and then i'll make one simular to it to decode the cookie. create function encode($var){ $out_var = ''; $s = '0'; $e = '1'; $num_char = strlen($var); //WHILE NUMBER OF CHARACHTERS IS LESS THE THE NUMBER OF I while( $num_char < $i ){ $new_var = substr($var, $s, $e ) if( $new_var == a ){ $out_var .= '05'; }elseif( $new_var == b ){ $out_var .= '18'; }elseif( $new_var == c ){ $out_var .= '06'; }elseif( $new_var == d ){ $out_var .= '19'; }elseif( $new_var == e ){ $out_var .= '07'; }elseif( $new_var == f ){ $out_var .= '20'; }elseif( $new_var == g ){ $out_var .= '08'; }elseif( $new_var == h ){ $out_var .= '21'; }elseif( $new_var == i ){ $out_var .= '09'; }elseif( $new_var == j ){ $out_var .= '22'; }elseif( $new_var == k ){ $out_var .= '10'; }elseif( $new_var == l ){ $out_var .= '23'; }elseif( $new_var == m ){ $out_var .= '11'; }elseif( $new_var == n ){ $out_var .= '24'; }elseif( $new_var == o ){ $out_var .= '12'; }elseif( $new_var == p ){ $out_var .= '25'; }elseif( $new_var == q ){ $out_var .= '13'; }elseif( $new_var == r ){ $out_var .= '26'; }elseif( $new_var == s ){ $out_var .= '14'; }elseif( $new_var == t ){ $out_var .= '01'; }elseif( $new_var == u ){ $out_var .= '15'; }elseif( $new_var == v ){ $out_var .= '02'; }elseif( $new_var == w ){ $out_var .= '16'; }elseif( $new_var == x ){ $out_var .= '03'; }elseif( $new_var == y ){ $out_var .= '17'; }elseif( $new_var == z ){ $out_var .= '04'; }else{ echo 'encoding did not work.' exit; } $s++; $e++; $i++ } return $out_var; } now i'm sure theres some errors in there but i'm at work so it's just a quick idea, and i need to know somehting like this would work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.