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 3y 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 2w 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

21

—

LowBetter than 17% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

1214d 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

[nystudio107/craft3-multi-environment

Efficient and flexible multi-environment config for Craft 3 CMS

7218.5k5](/packages/nystudio107-craft3-multi-environment)[yii2mod/yii2-selectize

selectize.js wrapper for yii2

1731.5k1](/packages/yii2mod-yii2-selectize)[soup/paginator

Paginator is a simple class that allows you to create pagination. It doesn't require any database connection. It is compatible with Twitter's Bootstrap Framework, by using the CSS class pagination that is also attached.

351.6k](/packages/soup-paginator)

PHPackages © 2026

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