From 9734db849242113571ed30ed44591ca7025389cc Mon Sep 17 00:00:00 2001 From: narkunan Date: Sun, 12 Jul 2026 20:31:47 +0530 Subject: [PATCH 1/7] Removed strict type comments from simplecipher test file --- .../simple-cipher/SimpleCipherTest.php | 130 +++++++++--------- 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/exercises/practice/simple-cipher/SimpleCipherTest.php b/exercises/practice/simple-cipher/SimpleCipherTest.php index 0afe690c3..051730dcc 100644 --- a/exercises/practice/simple-cipher/SimpleCipherTest.php +++ b/exercises/practice/simple-cipher/SimpleCipherTest.php @@ -1,29 +1,7 @@ . - * - * To disable strict typing, comment out the directive below. - */ - -declare(strict_types=1); +use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; class SimpleCipherTest extends TestCase @@ -33,17 +11,14 @@ public static function setUpBeforeClass(): void require_once 'SimpleCipher.php'; } - public function testRandomCipherKeyIsLetters(): void - { - $cipher = new SimpleCipher(); - $this->assertMatchesRegularExpression('/\A[a-z]+\z/', $cipher->key); - } - /** * Here we take advantage of the fact that plaintext of "aaa..." doesn't * output the key. This is a critical problem with shift ciphers, some * characters will always output the key verbatim. + * + * Uuid: b8bdfbe1-bea3-41bb-a999-b41403f2b15d. */ + #[TestDox('Random key cipher -> Can encode')] public function testRandomKeyCipherEncode(): void { $cipher = new SimpleCipher(); @@ -51,6 +26,10 @@ public function testRandomKeyCipherEncode(): void $this->assertEquals(substr($cipher->key, 0, 10), $cipher->encode($plaintext)); } + /** + * Uuid: 3dff7f36-75db-46b4-ab70-644b3f38b81c. + */ + #[TestDox('Random key cipher -> Can decode')] public function testRandomKeyCipherDecode(): void { $cipher = new SimpleCipher(); @@ -58,6 +37,10 @@ public function testRandomKeyCipherDecode(): void $this->assertEquals($plaintext, $cipher->decode(substr($cipher->key, 0, 10))); } + /** + * Uuid: 8143c684-6df6-46ba-bd1f-dea8fcb5d265. + */ + #[TestDox('Random key cipher -> Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method')] public function testRandomKeyCipherReversible(): void { $cipher = new SimpleCipher(); @@ -65,30 +48,20 @@ public function testRandomKeyCipherReversible(): void $this->assertEquals($plaintext, $cipher->decode($cipher->encode($plaintext))); } - public function testCipherWithCapsKey(): void - { - $this->expectException(InvalidArgumentException::class); - $cipher = new SimpleCipher('ABCDEF'); - } - - public function testCipherWithNumericKey(): void - { - $this->expectException(InvalidArgumentException::class); - $cipher = new SimpleCipher('12345'); - } - - public function testCipherWithEmptyKey(): void - { - $this->expectException(InvalidArgumentException::class); - $cipher = new SimpleCipher(''); - } - - public function testCipherKeyIsAsSubmitted(): void + /** + * Uuid: defc0050-e87d-4840-85e4-51a1ab9dd6aa. + */ + #[TestDox('Random key cipher -> Key is made only of lowercase letters')] + public function testRandomCipherKeyIsLetters(): void { - $cipher = new SimpleCipher('abcdefghij'); - $this->assertEquals($cipher->key, 'abcdefghij'); + $cipher = new SimpleCipher(); + $this->assertMatchesRegularExpression('/\A[a-z]+\z/', $cipher->key); } + /** + * Uuid: 565e5158-5b3b-41dd-b99d-33b9f413c39f. + */ + #[TestDox('Substitution cipher -> Can encode')] public function testCipherEncode(): void { $cipher = new SimpleCipher('abcdefghij'); @@ -97,6 +70,10 @@ public function testCipherEncode(): void $this->assertEquals($ciphertext, $cipher->encode($plaintext)); } + /** + * Uuid: d44e4f6a-b8af-4e90-9d08-fd407e31e67b. + */ + #[TestDox('Substitution cipher -> Can decode')] public function testCipherDecode(): void { $cipher = new SimpleCipher('abcdefghij'); @@ -105,6 +82,10 @@ public function testCipherDecode(): void $this->assertEquals($plaintext, $cipher->decode($ciphertext)); } + /** + * Uuid: 70a16473-7339-43df-902d-93408c69e9d1. + */ + #[TestDox('Substitution cipher -> Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method')] public function testCipherReversible(): void { $cipher = new SimpleCipher('abcdefghij'); @@ -112,6 +93,10 @@ public function testCipherReversible(): void $this->assertEquals($plaintext, $cipher->decode($cipher->encode($plaintext))); } + /** + * Uuid: 69a1458b-92a6-433a-a02d-7beac3ea91f9. + */ + #[TestDox('Substitution cipher -> Can double shift encode')] public function testDoubleShiftEncode(): void { $cipher = new SimpleCipher('iamapandabear'); @@ -120,6 +105,10 @@ public function testDoubleShiftEncode(): void $this->assertEquals($ciphertext, $cipher->encode($plaintext)); } + /** + * Uuid: 21d207c1-98de-40aa-994f-86197ae230fb. + */ + #[TestDox('Substitution cipher -> Can wrap on encode')] public function testCipherEncodeWrap(): void { $cipher = new SimpleCipher('abcdefghij'); @@ -128,26 +117,39 @@ public function testCipherEncodeWrap(): void $this->assertEquals($ciphertext, $cipher->encode($plaintext)); } - public function testShiftCipherEncode(): void + /** + * Uuid: a3d7a4d7-24a9-4de6-bdc4-a6614ced0cb3. + */ + #[TestDox('Substitution cipher -> Can wrap on decode')] + public function testCipherDecodeWrap(): void { - $cipher = new SimpleCipher('dddddddddd'); - $plaintext = 'aaaaaaaaaa'; - $ciphertext = 'dddddddddd'; - $this->assertEquals($ciphertext, $cipher->encode($plaintext)); + $cipher = new SimpleCipher('abcdefghij'); + $plaintext = 'zzzzzzzzzz'; + $ciphertext = 'zabcdefghi'; + $this->assertEquals($plaintext, $cipher->decode($ciphertext)); } - public function testShiftCipherDecode(): void + /** + * Uuid: e31c9b8c-8eb6-45c9-a4b5-8344a36b9641. + */ + #[TestDox('Substitution cipher -> Can encode messages longer than the key')] + public function testCanEncodeMessageLongerThanKey(): void { - $cipher = new SimpleCipher('dddddddddd'); - $plaintext = 'aaaaaaaaaa'; - $ciphertext = 'dddddddddd'; - $this->assertEquals($plaintext, $cipher->decode($ciphertext)); + $cipher = new SimpleCipher('abc'); + $cipherText = 'iboaqcnecbfcr'; + $plainText = 'iamapandabear'; + $this->assertEquals($cipherText, $cipher->encode($plainText)); } - public function testShiftCipherReversible(): void + /** + * Uuid: 93cfaae0-17da-4627-9a04-d6d1e1be52e3. + */ + #[TestDox('Substitution cipher -> Can decode messages longer than the key')] + public function testCanDecodeMessageLongerThanKey(): void { - $cipher = new SimpleCipher('dddddddddd'); - $plaintext = 'abcdefghij'; - $this->assertEquals($plaintext, $cipher->decode($cipher->encode($plaintext))); + $cipher = new SimpleCipher('abc'); + $cipherText = 'iboaqcnecbfcr'; + $plainText = 'iamapandabear'; + $this->assertEquals($plainText, $cipher->decode($cipherText)); } } From d23326122aaecf11506712f4fbaf7d37aa8f8a5b Mon Sep 17 00:00:00 2001 From: narkunan Date: Sun, 12 Jul 2026 20:32:10 +0530 Subject: [PATCH 2/7] Removed Strict type comments from example.php --- .../practice/simple-cipher/.meta/example.php | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/exercises/practice/simple-cipher/.meta/example.php b/exercises/practice/simple-cipher/.meta/example.php index 9b48ced8f..9d4064691 100644 --- a/exercises/practice/simple-cipher/.meta/example.php +++ b/exercises/practice/simple-cipher/.meta/example.php @@ -1,29 +1,5 @@ . - * - * To disable strict typing, comment out the directive below. - */ - -declare(strict_types=1); - class SimpleCipher { public const LETTERS = "abcdefghijklmnopqrstuvwxyz"; From fa8a1a1244b280e2888fdf220e35da54813e262f Mon Sep 17 00:00:00 2001 From: narkunan Date: Sun, 12 Jul 2026 20:32:27 +0530 Subject: [PATCH 3/7] Synced Instructions.md file --- exercises/practice/simple-cipher/.docs/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/simple-cipher/.docs/instructions.md b/exercises/practice/simple-cipher/.docs/instructions.md index 950953bfa..afd0b57da 100644 --- a/exercises/practice/simple-cipher/.docs/instructions.md +++ b/exercises/practice/simple-cipher/.docs/instructions.md @@ -1,4 +1,4 @@ -# Description +# Instructions Create an implementation of the [Vigenère cipher][wiki]. The Vigenère cipher is a simple substitution cipher. From cf210cf9b02a806a9cc3f5e557cd289874a384be Mon Sep 17 00:00:00 2001 From: narkunan Date: Sun, 12 Jul 2026 20:32:40 +0530 Subject: [PATCH 4/7] Added tests.toml --- .../practice/simple-cipher/.meta/tests.toml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 exercises/practice/simple-cipher/.meta/tests.toml diff --git a/exercises/practice/simple-cipher/.meta/tests.toml b/exercises/practice/simple-cipher/.meta/tests.toml new file mode 100644 index 000000000..77e6571e4 --- /dev/null +++ b/exercises/practice/simple-cipher/.meta/tests.toml @@ -0,0 +1,46 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[b8bdfbe1-bea3-41bb-a999-b41403f2b15d] +description = "Random key cipher -> Can encode" + +[3dff7f36-75db-46b4-ab70-644b3f38b81c] +description = "Random key cipher -> Can decode" + +[8143c684-6df6-46ba-bd1f-dea8fcb5d265] +description = "Random key cipher -> Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method" + +[defc0050-e87d-4840-85e4-51a1ab9dd6aa] +description = "Random key cipher -> Key is made only of lowercase letters" + +[565e5158-5b3b-41dd-b99d-33b9f413c39f] +description = "Substitution cipher -> Can encode" + +[d44e4f6a-b8af-4e90-9d08-fd407e31e67b] +description = "Substitution cipher -> Can decode" + +[70a16473-7339-43df-902d-93408c69e9d1] +description = "Substitution cipher -> Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method" + +[69a1458b-92a6-433a-a02d-7beac3ea91f9] +description = "Substitution cipher -> Can double shift encode" + +[21d207c1-98de-40aa-994f-86197ae230fb] +description = "Substitution cipher -> Can wrap on encode" + +[a3d7a4d7-24a9-4de6-bdc4-a6614ced0cb3] +description = "Substitution cipher -> Can wrap on decode" + +[e31c9b8c-8eb6-45c9-a4b5-8344a36b9641] +description = "Substitution cipher -> Can encode messages longer than the key" + +[93cfaae0-17da-4627-9a04-d6d1e1be52e3] +description = "Substitution cipher -> Can decode messages longer than the key" From fdadef0bae49570ed5b96e948b2db86f550ba9cd Mon Sep 17 00:00:00 2001 From: narkunan Date: Sun, 12 Jul 2026 20:32:59 +0530 Subject: [PATCH 5/7] Updated config.json with author name --- exercises/practice/simple-cipher/.meta/config.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/exercises/practice/simple-cipher/.meta/config.json b/exercises/practice/simple-cipher/.meta/config.json index b06444a06..e5b367ddd 100644 --- a/exercises/practice/simple-cipher/.meta/config.json +++ b/exercises/practice/simple-cipher/.meta/config.json @@ -1,6 +1,7 @@ { "authors": [ - "camilopayan" + "camilopayan", + "Narkunan" ], "contributors": [ "MichaelBunker" @@ -16,5 +17,7 @@ ".meta/example.php" ] }, - "blurb": "Implement a simple shift cipher like Caesar and a more secure substitution cipher" + "blurb": "Implement the Vigenère cipher, a simple substitution cipher.", + "source": "Substitution Cipher at Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Substitution_cipher" } From 4507f0fd163605e24bc42d3b0c007ada424b51ac Mon Sep 17 00:00:00 2001 From: narkunan Date: Sun, 12 Jul 2026 20:34:04 +0530 Subject: [PATCH 6/7] Added simple cipher in auto sync.txt --- bin/auto-sync.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/auto-sync.txt b/bin/auto-sync.txt index dbf3f3b33..1cf5e07c2 100644 --- a/bin/auto-sync.txt +++ b/bin/auto-sync.txt @@ -84,6 +84,7 @@ scrabble-score secret-handshake series sieve +simple-cipher space-age spiral-matrix square-root From a8987479560e1c6073be43d3a4758b1974b402aa Mon Sep 17 00:00:00 2001 From: narkunan Date: Sun, 12 Jul 2026 20:44:46 +0530 Subject: [PATCH 7/7] Fixed Linting issue --- exercises/practice/simple-cipher/SimpleCipherTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/practice/simple-cipher/SimpleCipherTest.php b/exercises/practice/simple-cipher/SimpleCipherTest.php index 051730dcc..d95906302 100644 --- a/exercises/practice/simple-cipher/SimpleCipherTest.php +++ b/exercises/practice/simple-cipher/SimpleCipherTest.php @@ -1,5 +1,6 @@