PHPackages                             maxoplata/string-thing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. maxoplata/string-thing

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

maxoplata/string-thing
======================

A lightweight library for encoding and decoding strings using various patterns.

v1.0.0(3y ago)05MITPHP

Since Apr 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Maxoplata/string-thing-php)[ Packagist](https://packagist.org/packages/maxoplata/string-thing)[ RSS](/packages/maxoplata-string-thing/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

StringThing
===========

[](#stringthing)

StringThing is a lightweight library for encoding and decoding strings using various patterns.

Installation
------------

[](#installation)

```
composer require string-thing
```

Usage
-----

[](#usage)

StringThing provides an API for encoding and decoding strings. To use it, import the StringThing class and create a new instance with an array of patterns in the order you want to use them:

```
use Maxoplata\StringThing;

$myString = 'This is my string';

// Create a new instance of StringThing with default pattern (['split-halves', 'reverse', 'shift', 'swap-case', 'rotate'])
$myStringThing = new StringThing();

// Encode the string
$encoded = $myStringThing->encode($myString);

// Output the encoded string
print encoded; // "ZN!TJ!TJIuHOJSUT!"

// Decode the string
$decoded = myStringThing->decode($encoded);

// Output the decoded string
print decoded; // "This is my string"
```

Patterns
--------

[](#patterns)

StringThing patterns currently support the following operations:

- `split-halves`: Splits the string into two halves and swaps them.
    - `Abcd12` =&gt; `d12Abc`
- `reverse`: Reverses the order of the characters in the string.
    - `Abcd12` =&gt; `21dcbA`
- `shift`: Shifts the characters in the string up by 1 in the ASCII table.
    - `Abcd12` =&gt; `Bcde23`
- `swap-case`: Swaps uppercase &amp; lowercase characters in the string.
    - `Abcd12` =&gt; `aBCD12`
- `rotate`: Shifts the string 1 position to the right.
    - `Abcd12` =&gt; `2Abcd1`

To use a specific pattern, pass it as an argument to the StringThing constructor:

```
use Maxoplata\StringThing;

$myStringThing1 = new StringThing(['split-halves', 'shift', 'reverse', 'shift', 'swap-case', 'rotate']);

// OR

$stringThingPattern = ['split-halves', 'shift', 'reverse', 'shift', 'swap-case', 'rotate'];
$myStringThing2 = new StringThing($stringThingPattern);
```

Example: Encoding Passwords for Secure Storage
----------------------------------------------

[](#example-encoding-passwords-for-secure-storage)

StringThing can be used to encode passwords before hashing them and storing them in a database, making it more difficult for an attacker to retrieve the original password even if they gain access to the database.

Here's an example of how to use StringThing to encode a password before hashing it with bcrypt when working with passwords in a database:

#### Create User:

[](#create-user)

```
use Maxoplata\StringThing;

$stringThingPattern = ['split-halves', 'shift', 'reverse', 'shift', 'swap-case', 'rotate'];

// The original password to be encoded and hashed
$password = 'myPassword123';

// Encode the password using StringThing
$encodedPassword = (new StringThing($stringThingPattern))->encode($password);

// Hash the encoded password with bcrypt
$hashedPassword = password_hash($encodedPassword, PASSWORD_BCRYPT);

// Add the hashed password to a user object for storage in a database
$user = [
  'username' => 'johndoe',
  'email' => 'johndoe@example.com',
  'password' => hashedPassword,
  // other user data...
];

// Add the user object to the database
myDatabase->addUser($user);
```

#### Authenticate User:

[](#authenticate-user)

```
use Maxoplata\StringThing;

$stringThingPattern = ['split-halves', 'shift', 'reverse', 'shift', 'swap-case', 'rotate'];

// Retrieve the user's hashed password and salt from the database
$user = $myDatabase->getUserByUsername('johndoe');
$hashedPassword = $user->password;

// The password entered by the user attempting to log in
$passwordAttempt = 'myPassword123';

// Encode the password attempt using StringThing
$encodedPasswordAttempt = (new StringThing($stringThingPattern))->encode($passwordAttempt);

// Hash the encoded password attempt with bcrypt
$hashedPasswordAttempt = password_hash($encodedPasswordAttempt, PASSWORD_BCRYPT);

// Compare the hashed password attempt to the stored hashed password
if ($hashedPasswordAttempt === $hashedPassword) {
  // Passwords match - login successful!
} else {
  // Passwords do not match - login failed
}
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1123d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c57a872e2e7254921dcd774d930fd347276e908ab0ad8492e28e3a654395c5f9?d=identicon)[Maxoplata](/maintainers/Maxoplata)

---

Top Contributors

[![Maxoplata](https://avatars.githubusercontent.com/u/850981?v=4)](https://github.com/Maxoplata "Maxoplata (3 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/maxoplata-string-thing/health.svg)

```
[![Health](https://phpackages.com/badges/maxoplata-string-thing/health.svg)](https://phpackages.com/packages/maxoplata-string-thing)
```

###  Alternatives

[leafo/lessphp

lessphp is a compiler for LESS written in PHP.

2.2k8.2M141](/packages/leafo-lessphp)[realrashid/sweet-alert

Laravel Sweet Alert Is A Package For Laravel Provides An Easy Way To Display Alert Messages Using The SweetAlert2 Library.

1.2k2.9M21](/packages/realrashid-sweet-alert)[symfony/polyfill-php55

Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions

10731.7M9](/packages/symfony-polyfill-php55)[helmich/typo3-typoscript-lint

Static code analysis for the TypoScript configuration language.

902.9M241](/packages/helmich-typo3-typoscript-lint)[cyclonedx/cyclonedx-php-composer

Creates CycloneDX Software Bill-of-Materials (SBOM) from PHP Composer projects

821.6M17](/packages/cyclonedx-cyclonedx-php-composer)[kartik-v/yii2-widget-touchspin

A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes &amp; radios as toggle touchspines (sub repo split from yii2-widgets)

184.1M6](/packages/kartik-v-yii2-widget-touchspin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
