Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Função para fazer a codificação
- * Use a true para esconder false para ver
- * criar codificação sem usar funções nativas
- */
- echo bruno("bruno", true);
- echo "<br>";
- echo bruno("csvop", false);
- // Nota: csvop equivale a bruno no codificador
- function bruno($string, $sim)
- {
- $resultado = '';
- $tamanho = strlenBruno($string);
- for($i = 0; $i < $tamanho; $i++)
- {
- $c = ordBruno($string{$i});
- $resultado .= $c > 254 ? $c : chrBruno($c + ($sim ? 1 : -1));
- }
- return $resultado;
- }
- /*
- * Funções abaixos utilizadas
- * para suprir as funções nativas
- */
- function strlenBruno($s) {
- $i = 0;
- while(!empty($s{++$i})) continue;
- return $i;
- }
- function ordBruno($c) {
- $ords = array('\0' =>0,'' =>1,'' =>2,'' =>3,'' =>4,'' =>5,'' =>6,'' =>7,'' =>8,' ' =>9,' ' =>10,'' =>11,'' =>12,' ' =>13,'' =>14,'' =>15,'' =>16,'' =>17,'' =>18,'' =>19,'' =>20,'' =>21,'' =>22,'' =>23,'' =>24,'' =>25,'' =>26,'' =>27,' ' =>32,'!' =>33,'\"' =>34,'#' =>35,'$' =>36,'%' =>37,'&' =>38,"'" =>39,'(' =>40,')' =>41,'*' =>42,'+' =>43,',' =>44,'-' =>45,'.' =>46,'/' =>47,'0' =>48,'1' =>49,'2' =>50,'3' =>51,'4' =>52,'5' =>53,'6' =>54,'7' =>55,'8' =>56,'9' =>57,':' =>58,';' =>59,'<' =>60,'=' =>61,'>' =>62,'?' =>63,'@' =>64,'A' =>65,'B' =>66,'C' =>67,'D' =>68,'E' =>69,'F' =>70,'G' =>71,'H' =>72,'I' =>73,'J' =>74,'K' =>75,'L' =>76,'M' =>77,'N' =>78,'O' =>79,'P' =>80,'Q' =>81,'R' =>82,'S' =>83,'T' =>84,'U' =>85,'V' =>86,'W' =>87,'X' =>88,'Y' =>89,'Z' =>90,'[' =>91,'\\' =>92,']' =>93,'^' =>94,'_' =>95,'`' =>96,'a' =>97,'b' =>98,'c' =>99,'d' =>100,'e' =>101,'f' =>102,'g' =>103,'h' =>104,'i' =>105,'j' =>106,'k' =>107,'l' =>108,'m' =>109,'n' =>110,'o' =>111,'p' =>112,'q' =>113,'r' =>114,'s' =>115,'t' =>116,'u' =>117,'v' =>118,'w' =>119,'x' =>120,'y' =>121,'z' =>122,'{' =>123,'|' =>124,'}' =>125,'~' =>126,'' =>127,'€' =>128,'' =>129,'‚' =>130,'ƒ' =>131,'„' =>132,'…' =>133,'†' =>134,'‡' =>135,'ˆ' =>136,'‰' =>137,'Š' =>138,'‹' =>139,'Œ' =>140,'' =>141,'Ž' =>142,'' =>143,'' =>144,'‘' =>145,'’' =>146,'“' =>147,'”' =>148,'•' =>149,'–' =>150,'—' =>151,'˜' =>152,'™' =>153,'š' =>154,'›' =>155,'œ' =>156,'' =>157,'ž' =>158,'Ÿ' =>159,' ' =>160,'¡' =>161,'¢' =>162,'£' =>163,'¤' =>164,'¥' =>165,'¦' =>166,'§' =>167,'¨' =>168,'©' =>169,'ª' =>170,'«' =>171,'¬' =>172,'-' =>173,'®' =>174,'¯' =>175,'°' =>176,'±' =>177,'²' =>178,'³' =>179,'´' =>180,'µ' =>181,'¶' =>182,'·' =>183,'¸' =>184,'¹' =>185,'º' =>186,'»' =>187,'¼' =>188,'½' =>189,'¾' =>190,'¿' =>191,'À' =>192,'Á' =>193,'Â' =>194,'Ã' =>195,'Ä' =>196,'Å' =>197,'Æ' =>198,'Ç' =>199,'È' =>200,'É' =>201,'Ê' =>202,'Ë' =>203,'Ì' =>204,'Í' =>205,'Î' =>206,'Ï' =>207,'Ð' =>208,'Ñ' =>209,'Ò' =>210,'Ó' =>211,'Ô' =>212,'Õ' =>213,'Ö' =>214,'×' =>215,'Ø' =>216,'Ù' =>217,'Ú' =>218,'Û' =>219,'Ü' =>220,'Ý' =>221,'Þ' =>222,'ß' =>223,'à' =>224,'á' =>225,'â' =>226,'ã' =>227,'ä' =>228,'å' =>229,'æ' =>230,'ç' =>231,'è' =>232,'é' =>233,'ê' =>234,'ë' =>235,'ì' =>236,'í' =>237,'î' =>238,'ï' =>239,'ð' =>240,'ñ' =>241,'ò' =>242,'ó' =>243,'ô' =>244,'õ' =>245,'ö' =>246,'÷' =>247,'ø' =>248,'ù' =>249,'ú' =>250,'û' =>251,'ü' =>252,'ý' =>253,'þ' =>254);
- return $ords[$c];
- }
- function chrBruno($i) {
- $chrs = array(0 => '\0',1 => '',2 => '',3 => '',4 => '',5 => '',6 => '',7 => '',8 => '',9 => ' ',10 => ' ',11 => '',12 => '',13 => ' ',14 => '',15 => '',16 => '',17 => '',18 => '',19 => '',20 => '',21 => '',22 => '',23 => '',24 => '',25 => '',26 => '',27 => '',28 => '',29 => '',30 => '',31 => '',32 => ' ',33 => '!',34 => '\"',35 => '#',36 => '$',37 => '%',38 => '&',39 => '\'',40 => '(',41 => ')',42 => '*',43 => '+',44 => ',',45 => '-',46 => '.',47 => '/',48 => '0',49 => '1',50 => '2',51 => '3',52 => '4',53 => '5',54 => '6',55 => '7',56 => '8',57 => '9',58 => ':',59 => ';',60 => '<',61 => '=',62 => '>',63 => '?',64 => '@',65 => 'A',66 => 'B',67 => 'C',68 => 'D',69 => 'E',70 => 'F',71 => 'G',72 => 'H',73 => 'I',74 => 'J',75 => 'K',76 => 'L',77 => 'M',78 => 'N',79 => 'O',80 => 'P',81 => 'Q',82 => 'R',83 => 'S',84 => 'T',85 => 'U',86 => 'V',87 => 'W',88 => 'X',89 => 'Y',90 => 'Z',91 => '[',92 => '\\',93 => ']',94 => '^',95 => '_',96 => '`',97 => 'a',98 => 'b',99 => 'c',100 => 'd',101 => 'e',102 => 'f',103 => 'g',104 => 'h',105 => 'i',106 => 'j',107 => 'k',108 => 'l',109 => 'm',110 => 'n',111 => 'o',112 => 'p',113 => 'q',114 => 'r',115 => 's',116 => 't',117 => 'u',118 => 'v',119 => 'w',120 => 'x',121 => 'y',122 => 'z',123 => '{',124 => '|',125 => '}',126 => '~',127 => '',128 => '€',129 => '',130 => '‚',131 => 'ƒ',132 => '„',133 => '…',134 => '†',135 => '‡',136 => 'ˆ',137 => '‰',138 => 'Š',139 => '‹',140 => 'Œ',141 => '',142 => 'Ž',143 => '',144 => '',145 => '‘',146 => '’',147 => '“',148 => '”',149 => '•',150 => '–',151 => '—',152 => '˜',153 => '™',154 => 'š',155 => '›',156 => 'œ',157 => '',158 => 'ž',159 => 'Ÿ',160 => ' ',161 => '¡',162 => '¢',163 => '£',164 => '¤',165 => '¥',166 => '¦',167 => '§',168 => '¨',169 => '©',170 => 'ª',171 => '«',172 => '¬',173 => '-',174 => '®',175 => '¯',176 => '°',177 => '±',178 => '²',179 => '³',180 => '´',181 => 'µ',182 => '¶',183 => '·',184 => '¸',185 => '¹',186 => 'º',187 => '»',188 => '¼',189 => '½',190 => '¾',191 => '¿',192 => 'À',193 => 'Á',194 => 'Â',195 => 'Ã',196 => 'Ä',197 => 'Å',198 => 'Æ',199 => 'Ç',200 => 'È',201 => 'É',202 => 'Ê',203 => 'Ë',204 => 'Ì',205 => 'Í',206 => 'Î',207 => 'Ï',208 => 'Ð',209 => 'Ñ',210 => 'Ò',211 => 'Ó',212 => 'Ô',213 => 'Õ',214 => 'Ö',215 => '×',216 => 'Ø',217 => 'Ù',218 => 'Ú',219 => 'Û',220 => 'Ü',221 => 'Ý',222 => 'Þ',223 => 'ß',224 => 'à',225 => 'á',226 => 'â',227 => 'ã',228 => 'ä',229 => 'å',230 => 'æ',231 => 'ç',232 => 'è',233 => 'é',234 => 'ê',235 => 'ë',236 => 'ì',237 => 'í',238 => 'î',239 => 'ï',240 => 'ð',241 => 'ñ',242 => 'ò',243 => 'ó',244 => 'ô',245 => 'õ',246 => 'ö',247 => '÷',248 => 'ø',249 => 'ù',250 => 'ú',251 => 'û',252 => 'ü',253 => 'ý',254 => 'þ',255 => 'ÿ',256 => '\0',257 => '',258 => '',259 => '',260 => '',261 => '',262 => '',263 => '',264 => '',265 => ' ',266 => ' ',267 => '',268 => '',269 => ' ',270 => '',271 => '',272 => '',273 => '',274 => '',275 => '',276 => '',277 => '',278 => '',279 => '',280 => '',281 => '',282 => '',283 => '',284 => '',285 => '',286 => '',287 => '',288 => ' ',289 => '!',290 => '\"',291 => '#',292 => '$',293 => '%',294 => '&',295 => '\'',296 => '(',297 => ')',298 => '*',299 => '+',300 => ',',301 => '-',302 => '.',303 => '/',304 => '0',305 => '1',306 => '2',307 => '3',308 => '4',309 => '5',310 => '6',311 => '7',312 => '8',313 => '9',314 => ':',315 => ';',316 => '<',317 => '=',318 => '>',319 => '?',320 => '@',321 => 'A',322 => 'B',323 => 'C',324 => 'D',325 => 'E',326 => 'F',327 => 'G',328 => 'H',329 => 'I',330 => 'J',331 => 'K',332 => 'L',333 => 'M',334 => 'N',335 => 'O',336 => 'P',337 => 'Q',338 => 'R',339 => 'S',340 => 'T',341 => 'U',342 => 'V',343 => 'W',344 => 'X',345 => 'Y',346 => 'Z',347 => '[',348 => '\\',349 => ']',350 => '^',351 => '_',352 => '`',353 => 'a',354 => 'b',355 => 'c',356 => 'd',357 => 'e',358 => 'f',359 => 'g',360 => 'h',361 => 'i',362 => 'j',363 => 'k',364 => 'l',365 => 'm',366 => 'n',367 => 'o',368 => 'p',369 => 'q',370 => 'r',371 => 's',372 => 't',373 => 'u',374 => 'v',375 => 'w',376 => 'x',377 => 'y',378 => 'z',379 => '{',380 => '|',381 => '}',382 => '~',383 => '',384 => '€',385 => '',386 => '‚',387 => 'ƒ',388 => '„',389 => '…',390 => '†',391 => '‡',392 => 'ˆ',393 => '‰',394 => 'Š',395 => '‹',396 => 'Œ',397 => '',398 => 'Ž',399 => '',400 => '',401 => '‘',402 => '’',403 => '“',404 => '”',405 => '•',406 => '–',407 => '—',408 => '˜',409 => '™',410 => 'š',411 => '›',412 => 'œ',413 => '',414 => 'ž',415 => 'Ÿ',416 => ' ',417 => '¡',418 => '¢',419 => '£',420 => '¤',421 => '¥',422 => '¦',423 => '§',424 => '¨',425 => '©',426 => 'ª',427 => '«',428 => '¬',429 => '-',430 => '®',431 => '¯',432 => '°',433 => '±',434 => '²',435 => '³',436 => '´',437 => 'µ',438 => '¶',439 => '·',440 => '¸',441 => '¹',442 => 'º',443 => '»',444 => '¼',445 => '½',446 => '¾',447 => '¿',448 => 'À',449 => 'Á',450 => 'Â',451 => 'Ã',452 => 'Ä',453 => 'Å',454 => 'Æ',455 => 'Ç',456 => 'È',457 => 'É',458 => 'Ê',459 => 'Ë',460 => 'Ì',461 => 'Í',462 => 'Î',463 => 'Ï',464 => 'Ð',465 => 'Ñ',466 => 'Ò',467 => 'Ó',468 => 'Ô',469 => 'Õ',470 => 'Ö',471 => '×',472 => 'Ø',473 => 'Ù',474 => 'Ú',475 => 'Û',476 => 'Ü',477 => 'Ý',478 => 'Þ',479 => 'ß',480 => 'à',481 => 'á',482 => 'â',483 => 'ã',484 => 'ä',485 => 'å',486 => 'æ',487 => 'ç',488 => 'è',489 => 'é',490 => 'ê',491 => 'ë',492 => 'ì',493 => 'í',494 => 'î',495 => 'ï',496 => 'ð',497 => 'ñ',498 => 'ò',499 => 'ó');
- return $chrs[$i];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement