Git Product home page Git Product logo

xcv's Introduction

Updated 2024-05-14

Updating this repo to include the following shell functions snippet, as it's what I have aliased in my own dotfiles & offers a far simpler alternative. This repo was just a random excuse to do something in Rust (of which I have very, very little experience in ha) ๐Ÿ™‚

function tag_c() {
    local input_txt="${*:-$(
        read -r -p "Enter the text to convert and copy: " txt
        echo "${txt}"
    )}"

    fades -d pyperclip --exec python -c "import sys; import pyperclip;\
        pyperclip.copy(''.join(chr(0xE0000 + ord(ch)) for ch in \
        ' '.join(sys.argv[1:])))" "${input_txt}" &&
        echo "Converted text & copied converted text to clipboard."
}

function tag_v() { fades -d pyperclip --exec python -c "import pyperclip; print(''.join(chr(ord(ch) - 0xE0000) for ch in pyperclip.paste()))"; }

You'll need to install fades to make use of this. Just alias it somewhere and source the file in your own shell's *rc file.

Enjoy. ๐Ÿ˜‰


XCV Prompt Injection Clipboard Utility

XCV is a straightforward clipboard utility designed to convert text to and from Private Use Area characters (Wikipedia). These are characters that cannot be visibly seen, but LLMs can see plainly. A Twitter thread about AI prompt injection, which I learned about from the Critical Thinking - Bug Bounty Podcast (link goes to Spotify), inspired it.

Background

The idea for this project came from this Twitter thread, highlighting the potential use of this method for AI prompt injection. The thread offers valuable insights for developers about how seemingly harmless features can be exploited and why it's crucial to be aware of such vulnerabilities. (GPT wrote this for me, go get some insights โค๏ธ)

The name

Because x c v is easy and quick to type with one hand and I am meh at names.

Usage

Follow these steps to use the XCV Clipboard Utility:

  1. To convert text to Private Use Area characters and copy it to your clipboard:
    • Run xcv c in your terminal.
    • Enter the text you want to convert and press Enter.
    • The converted text is now copied to your clipboard.
  2. To convert text from Private Use Area characters back to normal text:
    • Run xcv v in your terminal.
    • The terminal will display the message converted back to plaintext.

For everything else, go ask a GPT ๐Ÿง™โ€โ™‚๏ธ

Building

To build and install the XCV Clipboard Utility, follow these steps:

  1. Clone the repository to your local machine using the following command:
git clone https://github.com/Alchemyst0x/xcv.git
  1. Navigate to the cloned directory:
cd xcv
  1. Build the project using Cargo, Rust's package manager and build system:
cargo build --release
  1. After the build is complete, you can find the executable in the target/release directory. To use the utility globally, move the executable to a directory included in your system's PATH environment variable, or simply invoke it from the current directory. For example:
mv target/release/xcv /usr/local/bin/

or, if you prefer to use it without moving:

./target/release/xcv

By following these steps, you'll have the XCV Clipboard Utility ready to use on your system.

Example

$ xcv c
Enter the text to convert and copy: write something here
Converted text copied to clipboard.
$ xcv v
Converted back text: write something here
# output:
# ๓ ท๓ ฒ๓ ฉ๓ ด๓ ฅ๓ € ๓ ณ๓ ฏ๓ ญ๓ ฅ๓ ด๓ จ๓ ฉ๓ ฎ๓ ง๓ € ๓ จ๓ ฅ๓ ฒ๓ ฅ

Output:

./img/example.jpg

Credits

  • The original Twitter thread, everyone involved, and the podcast mentioned above.
  • 1Password/arboard Arboard is a cross-platform clipboard library written in rust. It's used in this code, and the repository is regularly updated.

License

This project is licensed under the MIT license.

xcv's People

Contributors

alchemyst0x avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.