Skip to content
Cognitive-ProofPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VSRMark

VSRMark is a steganographic text encoding algorithm that hides a secret message inside ordinary-looking Unicode text using Unicode Variation Selectors.


Implementations

VSRMark is implemented in multiple languages. Each implementation includes a test suite that validates encoding, decoding, round-trip correctness, capacity limits, and CRC integrity:

Language Implementation Tests
C C/vsrmark.c C/vsrmark_test.c
Go Go/vsrmark.go Go/vsrmark_test.go
Java Java/VSRMark.java Java/VSRMarkTest.java
Rust Rust/src/lib.rs inline #[cfg(test)] module in lib.rs
Swift Swift/Sources/VSRMark/VSRMark.swift Swift/Tests/VSRMarkTests/VSRMarkTests.swift
TypeScript TypeScript/vsrmark.ts —

Overview

This document describes the VSRMark steganographic text encoding algorithm that hides a secret message inside ordinary-looking Unicode text using Unicode Variation Selectors.

The algorithm encodes hidden data by converting a secret message into bytes and then mapping each byte to a Unicode Variation Selector. These variation selector characters are appended after visible characters in the carrier text. Because variation selectors usually do not visibly render on their own, the resulting text appears unchanged to a human reader while still carrying hidden data.

This technique is steganography, not encryption. The hidden message is concealed, but it is not cryptographically protected. Anyone who knows the encoding method can recover the hidden message.


Core Concept

Unicode Variation Selectors are code points used to request alternate visual forms of a preceding character. This algorithm repurposes them to store hidden data.

The key idea is:

One visible Unicode character can carry one hidden byte by appending one variation selector after it.

For example, conceptually:

Visible text:
Hello

Encoded text:
H[hidden byte]e[hidden byte]l[hidden byte]l[hidden byte]o[hidden byte]

The variation selectors are present in the string, but they are usually invisible or visually insignificant.


Byte-to-Variation-Selector Mapping

The algorithm maps each possible byte value, from 0 to 255, to a unique Unicode Variation Selector.

There are two Unicode ranges used:

U+FE00  to U+FE0F
U+E0100 to U+E01EF

The mapping is:

Byte 0   → U+FE00
Byte 1   → U+FE01
...
Byte 15  → U+FE0F

Byte 16  → U+E0100
Byte 17  → U+E0101
...
Byte 255 → U+E01EF

In pseudocode:

function byteToVariationSelector(byte):
    if byte < 16:
        return codePoint(U+FE00 + byte)

    return codePoint(U+E0100 + byte - 16)

This gives exactly 256 possible variation selectors, which is enough to represent every possible byte.


Secret Block Format

The hidden message is not embedded directly. First, it is converted into a structured secret block.

The block format is:

Magic bytes | Version | Payload length | Payload | CRC32

More specifically:

4 bytes  - Magic value: "VSR1"
1 byte   - Version number
2 bytes  - Payload length, big-endian unsigned integer
N bytes  - UTF-8 encoded secret message
4 bytes  - CRC32 checksum

The complete structure is:

[0x56, 0x53, 0x52, 0x31] [0x01] [length_hi, length_lo] [payload] [crc32]

The magic bytes spell:

VSR1

The version byte is currently:

1

The payload length is stored as a 16-bit unsigned integer, so the maximum hidden message size is:

65,535 UTF-8 bytes

The CRC32 checksum is calculated over everything except the checksum itself:

magic + version + length + payload

This allows the decoder to verify that the recovered hidden message is valid.


Encoding Process

Step 1: Convert the Secret Message to UTF-8

The secret message is converted into UTF-8 bytes.

Example:

"Hi" → [0x48, 0x69]

If the UTF-8 payload is longer than 65,535 bytes, encoding fails.


Step 2: Build the Secret Block

The encoder constructs the full hidden block:

header = magic + version + payloadLength
checksum = crc32(header + payload)
secretBlock = header + payload + checksum

The secret block contains both the message and enough metadata to recognize and validate it later.


Step 3: Clean the Carrier Text

Before embedding the new hidden data, the algorithm strips any existing variation selectors from the carrier text.

It removes characters from these ranges:

U+FE00  to U+FE0F
U+E0100 to U+E01EF

This prevents old hidden data from mixing with new hidden data.


Step 4: Check Carrier Capacity

The carrier text must contain enough visible Unicode characters to store the entire secret block.

Because each visible character can carry one byte, the required carrier length is:

secretBlock.length

The secret block has an 11-byte overhead:

4 bytes magic
1 byte version
2 bytes length
4 bytes CRC32
= 11 bytes overhead

Therefore, a secret message of N UTF-8 bytes requires at least:

N + 11 visible characters

If the carrier text is too short, the algorithm leaves it unchanged.


Step 5: Append Hidden Variation Selectors

The carrier text is split into Unicode characters.

For each visible character, the encoder appends one variation selector representing one byte from the secret block.

Pseudocode:

function encodeCarrierCharacters(carrier, secretBlock):
    result = []

    for each character at index i in carrier:
        output = character

        if i < secretBlock.length:
            output = output + byteToVariationSelector(secretBlock[i])

        result.push(output)

    return join(result)

Characters after the secret block has been fully embedded are left unchanged.


Decoding Process

Step 1: Extract Hidden Bytes

The decoder scans the text for variation selectors.

Whenever it finds a variation selector, it converts it back into the byte it represents.

The reverse mapping is:

U+FE00  to U+FE0F  → bytes 0 to 15
U+E0100 to U+E01EF → bytes 16 to 255

Pseudocode:

function variationSelectorToByte(codePoint):
    if codePoint is between U+FE00 and U+FE0F:
        return codePoint - U+FE00

    if codePoint is between U+E0100 and U+E01EF:
        return 16 + (codePoint - U+E0100)

    return undefined

The result is a stream of recovered hidden bytes.


Step 2: Search for the Magic Header

The decoder scans the recovered byte stream looking for the expected magic value and version:

"VSR1" + version 1

In byte form:

0x56 0x53 0x52 0x31 0x01

This allows the decoder to find the beginning of a valid hidden message, even if the text contains unrelated variation selectors.


Step 3: Read the Payload Length

Once the decoder finds the magic header, it reads the next two bytes as a big-endian unsigned 16-bit integer.

payloadLength = length_hi << 8 | length_lo

This tells the decoder how many bytes to read as the hidden message payload.


Step 4: Extract the Payload and CRC32

The decoder calculates the payload boundaries:

payloadStart = start + 7
payloadEnd = payloadStart + payloadLength
crcStart = payloadEnd
crcEnd = payloadEnd + 4

It then reads:

payload = bytes[payloadStart:payloadEnd]
storedCrc = bytes[payloadEnd:payloadEnd + 4]

If the block is incomplete, the decoder ignores it and continues searching.


Step 5: Validate the CRC32

The decoder recomputes the CRC32 over:

magic + version + length + payload

It compares the recomputed CRC32 to the stored CRC32.

If they match, the block is considered valid.

If they do not match, the decoder continues scanning for another possible valid block.


Step 6: Decode the Payload

Once a valid block is found, the payload bytes are decoded as UTF-8.

The result is the recovered hidden message.


Encoding Pseudocode

function encode(secretMessage, carrierText):
    payload = UTF8Encode(secretMessage)

    if payload.length > 65535:
        throw error

    magic = bytes("VSR1")
    version = byte(1)
    length = uint16BigEndian(payload.length)

    header = magic + version + length
    checksum = uint32BigEndian(crc32(header + payload))

    secretBlock = header + payload + checksum

    cleanedCarrier = removeVariationSelectors(carrierText)

    if visibleCharacterCount(cleanedCarrier) < secretBlock.length:
        return cleanedCarrier

    result = ""

    for i from 0 to cleanedCarrier.length - 1:
        result += cleanedCarrier[i]

        if i < secretBlock.length:
            result += byteToVariationSelector(secretBlock[i])

    return result

Decoding Pseudocode

function decode(text):
    hiddenBytes = []

    for each codePoint in text:
        byte = variationSelectorToByte(codePoint)

        if byte is defined:
            hiddenBytes.push(byte)

    minimumLength = 11

    for start from 0 to hiddenBytes.length - minimumLength:
        if hiddenBytes[start:start+4] is not bytes("VSR1"):
            continue

        if hiddenBytes[start + 4] is not 1:
            continue

        payloadLength = uint16BigEndian(hiddenBytes[start + 5:start + 7])

        payloadStart = start + 7
        payloadEnd = payloadStart + payloadLength
        blockEnd = payloadEnd + 4

        if blockEnd > hiddenBytes.length:
            continue

        storedCrc = uint32BigEndian(hiddenBytes[payloadEnd:blockEnd])
        actualCrc = crc32(hiddenBytes[start:payloadEnd])

        if storedCrc == actualCrc:
            return UTF8Decode(hiddenBytes[payloadStart:payloadEnd])

    return undefined

Capacity

The algorithm stores:

1 hidden byte per visible Unicode character

However, the metadata overhead is 11 bytes.

Therefore:

maximum payload size = visible character count - 11

For example:

100 visible characters → 89 bytes of usable hidden payload
1,000 visible characters → 989 bytes of usable hidden payload
10,000 visible characters → 9,989 bytes of usable hidden payload

The payload limit is also capped at 65,535 bytes because the length field is two bytes.


Security Characteristics

This algorithm provides concealment, not cryptographic security.

It does not encrypt the hidden message. Anyone who knows the scheme can extract the variation selectors and decode the payload.

For sensitive data, the payload should be encrypted before being passed into this encoding algorithm.

Recommended security layering:

plaintext secret
→ encrypt secret
→ encode encrypted bytes as text-safe data
→ embed using variation selectors

Robustness Considerations

The hidden data may be lost if the text passes through systems that modify or sanitize Unicode.

Potential risks include:

  • Unicode normalization
  • Copy/paste cleaning
  • Markdown sanitization
  • HTML sanitization
  • Plain-text export
  • Database collation or filtering
  • Messaging apps that strip unknown code points
  • Search indexing systems
  • Text editors that remove invisible characters

The CRC32 check helps detect corruption, but it does not prevent corruption.


Advantages

This approach has several useful properties:

  1. The visible text remains mostly unchanged.
  2. The algorithm has deterministic encoding and decoding.
  3. The payload includes a recognizable magic header.
  4. The version byte allows future format changes.
  5. The payload length makes extraction precise.
  6. CRC32 allows accidental corruption to be detected.
  7. The scheme can represent arbitrary UTF-8 text.

Limitations

The main limitations are:

  1. The hidden message is not encrypted.
  2. The carrier text must be long enough.
  3. Unicode variation selectors may be stripped by some systems.
  4. Some fonts, renderers, or platforms may display unexpected behavior.
  5. The presence of variation selectors can be detected programmatically.
  6. CRC32 is not a security mechanism.
  7. The payload size is limited to 65,535 bytes.

Summary

The Unicode Variation Selector steganographic text encoder hides a structured byte payload inside visible text by appending invisible Unicode variation selectors after visible characters.

Each hidden byte is mapped to one variation selector. The payload is wrapped in a block containing a magic identifier, version number, payload length, and CRC32 checksum. The decoder extracts variation selectors, converts them back into bytes, searches for the magic header, validates the checksum, and returns the decoded UTF-8 message.

The result is a simple and effective text steganography method suitable for hiding metadata or identifiers in Unicode text, provided the text is not passed through systems that strip or normalize variation selectors.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages