As per Zubat's request (you better submit son).
Here is my formal contest, Submissions due by Nov 1st, voting will be publicly held the following three days.
This is something I've done in an entry level course to programming, so I believe everyone here should be able to participate.
50 B.C Julius Caeser used a simple substitution cipher to secure military and government communications. To form and encrypted text, Caeser shifted the letter of the alphabet three places. In addition to this mono-alphabetic substitution cipher, Caeser strengthened his encryption by substituting Greek letters for Latin letters.
This contest will be language-agnostic. So feel free to use javascript or auto-gayy4.
Post entries to PasteBin please, if you'd like to keep you entry anonymous send a pm.
Good Luck, and Have Fun!
=======
Entries
=======
1. gayChief
2. stapled
3. arti
Poll Results: 2014 - Most popular programmer goes to....
-
Arti
3 33.33% -
gameCheif
2 22.22% -
Stapled
4 44.44% -
Kings V
0 0%
You may not vote on this poll
9 Votes
Results 1 to 26 of 26
- 28 Oct. 2014 09:22pm #1
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
Halloween Contest - Caeser Cipher ***VOTE NOW***
Last edited by Kingz V; 02 Nov. 2014 at 03:05am.
https://discord.gg/TvN6xUb ~ chat on discord pls.
- 28 Oct. 2014 09:47pm #2
I don't get it. Is the contest to shit all the characters by 3 places? Or make both an encryption and decryption algorithm based on shifting letters?
- 28 Oct. 2014 10:04pm #3
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
A complete entry would need both encrypt/decrypt functions to verify that it works.
It's rather simple. a more complex contest would be an xor-key system, but that seemed a little complicated for a little friendly contest.Last edited by Kingz V; 28 Oct. 2014 at 10:07pm.
https://discord.gg/TvN6xUb ~ chat on discord pls.
- 28 Oct. 2014 11:58pm #4
So an encrpyt decrypt that shifts characters by 3?
- 29 Oct. 2014 12:07am #5
Shift characters by 2014.
Code:var HalloCrypt = function(str) { var chars = "HALOWENBCDFGIJKMPQRSTUVXYZ0123456789halowenbcdfgijkmpqrstuvxyz", encryption = "", loc, x; for (x = 0; x < str.length; x++) { loc = chars.indexOf(str[x]); // If the character is in our string of characters, edit it. if (loc != -1) { loc += 2014; loc = loc % chars.length; encryption += chars[loc]; } // Not an alphanumeric character, keep it the same. else encryption += str[x]; } return encryption; }; var DeHalloCrypt = function(str) { var chars = "HALOWENBCDFGIJKMPQRSTUVXYZ0123456789halowenbcdfgijkmpqrstuvxyz", encryption = "", loc, x; for (x = 0; x < str.length; x++) { loc = chars.indexOf(str[x]); // If the character is in our string of characters, edit it. if (loc != -1) { loc -= 2014; while (loc < 0) loc += chars.length; encryption += chars[loc]; } // Not an alphanumeric character, keep it the same. else encryption += str[x]; } return encryption; }; var a = HalloCrypt("This is a test of the emergency Logical Gamers system."); alert(a + "\n" + DeHalloCrypt(a));
Last edited by Stapled; 29 Oct. 2014 at 12:14am.
- 29 Oct. 2014 02:07am #6
Moderator Bachelor of Science in Virginity
- Age
- 31
- Join Date
- Nov. 2009
- Location
- Toronto
- Posts
- 5,421
- Reputation
- 546
- LCash (Rank 3)
- 1.96
My entry? Done in C#.
Code:private string strEnc(string text) { string encrypt = ""; byte[] bytes = System.Text.Encoding.UTF8.GetBytes(text); for (int c = 0; c <= bytes.Length-1; c++) { encrypt += Convert.ToChar(bytes[c] - 5); } return encrypt; } private string strDec(string text) { string decrypt = ""; byte[] bytes = System.Text.Encoding.UTF8.GetBytes(text); for (int c = 0; c <= bytes.Length - 1; c++) { decrypt += Convert.ToChar(bytes[c] + 5); } return decrypt; }
- 30 Oct. 2014 01:27pm #7
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
[Python] (lg) King Caeser Cipher - Pastebin.com
python all day.https://discord.gg/TvN6xUb ~ chat on discord pls.
- 31 Oct. 2014 05:44am #8
PHP. Left non-english characters alone so as not to screw with spaces, special chars, etc. Wasn't sure what to do with letters like z, so I just wrapped around (so z would become c).
PHP Code:namespace logicalgamers\contests;
class CaesarCypher
{
const LETTERS_IN_ALPHABET = 26;
const ENCRYPT = 1;
const DECRYPT = 0;
private $offset;
private $string;
private $flag;
public function __construct($string, $offset, $flag) {
$this->offset = $offset;
$this->string = $string;
$this->flag = $flag;
$this->execute();
}
private function execute() {
$this->string = implode('', array_map(function($c) {
if (! preg_match('/[a-zA-Z]/', $c)) {
return $c;
}
$char = chr(ord($c) + ($this->flag == self::ENCRYPT ?
$this->offset : 0 - $this->offset));
return preg_match('/[a-zA-Z]/', $char) ?
$char :
chr(ord($char) + ($this->flag == self::ENCRYPT ?
0 - self::LETTERS_IN_ALPHABET : self::LETTERS_IN_ALPHABET))
;
}, str_split($this->string)));
}
public function __toString() {
return $this->string;
}
}
PHP Code:var_dump((string) (new CaesarCypher('ABC wxyz', 3, CaesarCypher::ENCRYPT)) === 'DEF zabc');
var_dump((string) (new CaesarCypher('DEF zabc', 3, CaesarCypher::DECRYPT)) === 'ABC wxyz');
Code:bool(true) bool(true)
- 02 Nov. 2014 03:05am #9
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
Voting is now open, I set it open for 7 days.
May the most popular whore win.https://discord.gg/TvN6xUb ~ chat on discord pls.
- 02 Nov. 2014 05:24am #10
Banned Stupidly Smart™
Wigga Hack
- Join Date
- Aug. 2013
- Posts
- 1,601
- Reputation
- 5
- LCash
- 0.00
- Awards
I am now finding out about this contest x_x
- 03 Nov. 2014 06:46pm #11
Would have been a 3 way tie if I voted for myself. But I just didn't want Arti to win.
- 03 Nov. 2014 06:56pm #12
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
i should've included myself. x.x
there's still some time for votes.https://discord.gg/TvN6xUb ~ chat on discord pls.
- 03 Nov. 2014 09:11pm #13
- 03 Nov. 2014 11:51pm #14
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
Halloween Contest - Caeser Cipher
it's there, pastebin'dhttps://discord.gg/TvN6xUb ~ chat on discord pls.
- 04 Nov. 2014 01:14am #15
added u
- 04 Nov. 2014 01:28am #16
Voting on by plebeians. None of the other entries even work.
Code:static void Main() { Console.WriteLine(strEnc("ABC wxyz")); Console.ReadLine(); }
Code:Executing the program.... $mono demo.exe <=>rstu
- 04 Nov. 2014 01:33am #17
- 04 Nov. 2014 01:48am #18
Ignoring the fact that nobody (including myself since I omitted the greek/latin substitution) addresses the actual problem, everyone just shifts the character by 3 according to their ASCII value. gameCHIEFs goes one step further by checking the alphanumeric value prior to the encryption/decryption (which is silly, as z will be encrypted to a special char and then it will be unable to be decrypted), all of which can be rewritten as something as small as:
PHP Code:function crypt($str, $offset) { return implode('', array_map(function($c) { return preg_match('/[a-z]/i', $c) ? chr(ord($c) + $offset) : $c; }, str_split($str))) }
function encrypt($str) { return crypt($str, 3); }
function decrypt($str) { return crypt($str, -3); }
You all suck at programming. Get gud.
- 04 Nov. 2014 02:54am #19
Artficial wins. It's unanimous. Screw da poll. The man is just sitting here in this thread stylin' on yall.
Side note: I would've participated in this challenge if it didn't seem so darn uninteresting. I doubt my solution would've been as comprehensive as Art's, though.I'm lightning on my feet
- 04 Nov. 2014 02:57am #20
- 04 Nov. 2014 04:19am #21
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
Well this was fun, let's do it again next year.
https://discord.gg/TvN6xUb ~ chat on discord pls.
- 04 Nov. 2014 06:45am #22
If winner gets a badge or something
someone should come up with a clever name.
- 04 Nov. 2014 07:32am #23
Banned Stupidly Smart™
Wigga Hack
- Join Date
- Aug. 2013
- Posts
- 1,601
- Reputation
- 5
- LCash
- 0.00
- Awards
Halloweenie leaf
- 04 Nov. 2014 02:53pm #24
- Join Date
- Apr. 2013
- Location
- Minnesota
- Posts
- 1,325
- Reputation
- 114
- LCash
- 0.00
I had some awards picked out, but got lazy.
https://discord.gg/TvN6xUb ~ chat on discord pls.
- 04 Nov. 2014 07:13pm #25
- 27 Jul. 2017 12:46pm #26