EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff
Hacker's Home Page

Training Missions

Read Me First
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group

 

Affiliates

hackhound.org

suck-o.com

hack.org.za

flyninja.net

 

Enigma Group's Code Bank


cryptoFunctions

By: c0re  -  Date Submitted: 2010-09-03 07:12:19

  1. <?php
  2.  
  3. /***************************************************************************
  4.  * cryptoFunctions.php
  5.  * v1.0
  6.  * =================================================================
  7.  * contains functions to encode-decode/crypt-decrypt/cipher-encipher
  8.  * messages using a number of different methods, not included in php
  9.  *
  10.  ****************************************************************************
  11.  ****************************************************************************
  12.  * Changelog
  13.  * =========
  14.  * v 1.0 - 2010/09/03
  15.  * - initial release
  16.  * **************************************************************************/
  17.  
  18. //ASCII to Binary conversion
  19. function asc2bin($str) {
  20. $newstring = 0;
  21. $text_array = explode("\r\n", chunk_split($str, 1));
  22. for ($n = 0; $n < count($text_array) - 1; $n++) {
  23. $newstring .= substr("0000".base_convert(ord($text_array[$n]), 10, 2), -8);
  24. }
  25. $newstring = chunk_split($newstring, 8, " ");
  26. return $newstring;
  27. }
  28.  
  29. //Binary to ASCII conversion
  30. function bin2asc($str) {
  31. $newstring = 0;
  32. $str = str_replace(" ", "", $str);
  33. $text_array = explode("\r\n", chunk_split($str, 8));
  34. for ($n = 0; $n < count($text_array) - 1; $n++) {
  35. $newstring .= chr(base_convert($text_array[$n], 2, 10));
  36. }
  37. return $newstring;
  38. }
  39.  
  40. //ASCII to Hexadecimal conversion
  41. function asc2hex($str) {
  42. return chunk_split(bin2hex($str), 2, " ");
  43. }
  44.  
  45. //Hexadecimal to ASCII conversion
  46. function hex2asc($str) {
  47. $newstring = 0;
  48. $str = str_replace(" ", "", $str);
  49. for ($n=0; $n<strlen($str); $n+=2) {
  50. $newstring .= pack("C", hexdec(substr($str, $n, 2)));
  51. }
  52. return $newstring;
  53. }
  54.  
  55. //Binary to Hexadecimal conversion
  56. function binary2hex($str) {
  57. $newstring = 0;
  58. $str = str_replace(" ", "", $str);
  59. $text_array = explode("\r\n", chunk_split($str, 8));
  60. for ($n = 0; $n < count($text_array) - 1; $n++) {
  61. $newstring .= str_pad(base_convert($text_array[$n], 2, 16), 2, "0", STR_PAD_LEFT);
  62. }
  63. $newstring = chunk_split($newstring, 2, " ");
  64. return $newstring;
  65. }
  66.  
  67. //Hexadecimal to Binary conversion
  68. function hex2binary($str) {
  69. $newstring = 0;
  70. $str = str_replace(" ", "", $str);
  71. $text_array = explode("\r\n", chunk_split($str, 2));
  72. for ($n = 0; $n < count($text_array) - 1; $n++) {
  73. $newstring .= substr("0000".base_convert($text_array[$n], 16, 2), -8);
  74. }
  75. $newstring = chunk_split($newstring, 8, " ");
  76. return $newstring;
  77. }
  78.  
  79. //Ceasar Cipher Bruteforce <http://en.wikipedia.org/wiki/Caesar_cipher>
  80. function caesarbf($str) {
  81. $alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  82. echo "<table width=\"85%\" cellpadding=\"2\" align=\"center\">\n";
  83. for ($n = 1; $n < 26; $n++) {
  84. $cipher = substr($alpha, $n, 26 - $n) . substr($alpha, 0, $n) . substr($alpha, 26+$n, 52-$n) . substr($alpha, 26, $n);
  85. if ($n % 2 == 0) {
  86. echo '<tr bgcolor="#eeeeee">'; }
  87. else {
  88. echo '<tr bgcolor="#cccccc">';
  89. }
  90. echo "<td>ROT-$n: ". htmlentities(strtr($str, $alpha, $cipher)) ."</td>";
  91. }
  92. echo "<tr>\n</table>\n";
  93. }
  94.  
  95. //HTML encode
  96. function entityenc($str) {
  97. $newstring = 0;
  98. $text_array = explode("\r\n", chunk_split($str, 1));
  99. for ($n = 0; $n < count($text_array) - 1; $n++) {
  100. $newstring .= "&#" . ord($text_array[$n]) . ";";
  101. }
  102. return $newstring;
  103. }
  104.  
  105. //HTML decode
  106. function entitydec($str) {
  107. $newstring = 0;
  108. $str = str_replace(';', '; ', $str);
  109. $text_array = explode(' ', $str);
  110. for ($n = 0; $n < count($text_array) - 1; $n++) {
  111. $newstring .= chr(substr($text_array[$n], 2, 3));
  112. }
  113. return $newstring;
  114. }
  115.  
  116. //l33t 5pe4k encode <http://en.wikipedia.org/wiki/Leet>
  117. function l33t($str) {
  118. $newstring = 0;
  119. $from = 'ieastoIEASTO';
  120. $to = '134570134570';
  121. $newstring = strtr($str, $from, $to);
  122. return $newstring;
  123. }
  124.  
  125. //l33t 5pe4k decode <http://en.wikipedia.org/wiki/Leet>
  126. function del33t($str) {
  127. $newstring = 0;
  128. $from = '134570';
  129. $to = 'ieasto';
  130. $newstring = strtr($str, $from, $to);
  131. return $newstring;
  132. }
  133.  
  134. //Pig-Latin encode <http://en.wikipedia.org/wiki/PigLatin>
  135. function igpay($str) {
  136. $newstring = 0;
  137. $text_array = explode(" ", $str);
  138. for ($n = 0; $n < count($text_array); $n++) {
  139. $newstring .= substr($text_array[$n], 1) . substr($text_array[$n], 0, 1) . "ay ";
  140. }
  141. return $newstring;
  142. }
  143.  
  144. //Pig-Latin decode <http://en.wikipedia.org/wiki/PigLatin>
  145. function unigpay($str) {
  146. $newstring = 0;
  147. $text_array = explode(" ", $str);
  148. for ($n = 0; $n < count($text_array); $n++) {
  149. $newstring .= substr($text_array[$n], -3, 1) . substr($text_array[$n], 0, strlen($text_array[$n]) - 3) . " ";
  150. }
  151. return $newstring;
  152. }
  153.  
  154. //ROT13 DE/ENcode <http://en.wikipedia.org/wiki/Rot_13>
  155. function rot13($str) {
  156. $newstring = 0;
  157. $from = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  158. $to = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM';
  159. $newstring = strtr($str, $from, $to);
  160. return $newstring;
  161. }
  162.  
  163. //DE/ENchipher Atbash <http://en.wikipedia.org/wiki/Atbash>
  164. function atbash($str) {
  165. $newstring = 0;
  166. $from = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  167. $to = 'zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA';
  168. $newstring = strtr($str, $from, $to);
  169. return $newstring;
  170. }
  171.  
  172. //NOT A CRYPTO FUNCTION, BUT STILL KINDA USEFULL
  173. //strip spaces from a string
  174. function strip_spaces($str) {
  175. $str = str_replace(" ", "", $str);
  176. return $str;
  177. }
  178.  
  179. ?>
Return to php category list

Who Visited EnigmaGroup Today?

1388 Guests, 226 Users (217 Spiders)
cat1vo, Nightraven, lolzsec, interspirehost, lamb, Pabz, tgm001, plex, Edika, TheCheeseDemon, rockcraft, recoveryToolbox, saraf, soufiaane, sickmind, mjneat, famous0123, Galagatron, dark_void, CJ_Omaha, junaid_junaid59, JohnJohnJohn, ssmaslov, psychomarine, Dregoon, Patrickk, Aska, Beat_Slayer, M0rdak, Ausome1, Imre, Vreality2007, mmndglxuwn, m0rt, unholyblood, iterrumzz, VurbTrurb, Mayonoula, MAMWOURBROR, mutabor, gobinda, cossyDrybrich, Razin, zaCruBumas8, hunja, johny34, pantoufle, bagy, arctica, hackarchives, UsedDeteKef, Peculator, Fadhilat606, TheTrueMonarch, Pascall01, hackaday, Tjm, arndevil, flairvelocity, lol, alphbond, kdivanov, elizbethallis6, Rik, bn11, BorgBot, SHASHANK101hello, 4poc4lyptic, ksajxai, nbmorri1, electro-technic, شمالي عرعر, AutobotPrime, Underleaf, The End, tomtombomb, killobyte, snowgirlx, so_saucey, zerolife, Althor, Cramps, Hekser, Hyperborn, cyber-guard, jhgrunn, cobra, Partisan, MAZI_, cyborg, GenbreedX, moel77, cliptoX, pwnpwnlolz, letshavepie, Mrwormz, yshiau, mirmo, roozyoppomo, soft_devil, cls777, scoobywan, Reiversed, joshua, st3alth, Afrika, PaiffDryday, venter, Anthony12796, sh3llcod3, 8FIGURE, Rannim, Evil1, maloaboy, BACanON, SlayingDragons, Repuhlsive, IvanDimitriev, 1RiB, mzungudo, Micro_Geek, iMaxx, aciboummamymn, k0unterkulcher, somebody777, m14m16, GoododotAlcob, negasora, Rastii, UninueMem, Swifsolja, ad.conquest, ngolatkar, Infinity8, Jigoku, thesupervisor, p0is0n5ting, kernel_mod, AKL, GothicLogic, themastersinner, dnatrixene135, ChewBigRed, kalak55, sejem, cve916, pollolololo, triecturn, Violatedsmurf, Ops, jmp, xsiemich, generalisimo, strudels, ga3ttpom, KingOfBritains, epoch_qwert, suten, FriskyKat, Ryuske, Adonis Achilles, ubqbcdzzhf, 3vil, US£RNAM£, Weindittewcon, Batesheelocot, GSmyrlis, MaxMeier, Elite.America, rabbidmind, Psiber_Syn, phoenix22, imittyerrotte, peewster, cyberturtle, ctb, dexgeda, sdw, Pizza, White_widdow, devarian, finesse, Nature112091777, Danc7171, Alphadragon, Estadagause, 53QR10U5, Xargos, Alkomage, hardlock, Barry Gonzoles, MineDweller, Gkjt, N4g4c3N, [I]nfectedbug, wimsteege, aqr5zdcw, xin214, Bugshuppy, SnoopSky, Hessesian, voodooKobra, sKcarr, IROverRated, W1F1G3NJU75U, Baddy, ziadmosaan, gamble86, realzs, CruelDemon, Shinju, aVoid, aquiredanonymity, kukumumu, web_request, callmeneon, KissMyDAFFODIL, Feld Grau, Abhinav2107, prabhataditya, mbuyiselo, shumer, phenom216, princennamdi, huskyboiza, ninety-nine
 
Enigma Group