Giter Club home page Giter Club logo

tripcodes.rlib's Introduction

Tripcode

(c) 2016-2022 Huton & Fredrick Brennan

Build Status Current Version

Documentation

README日本語版

A Rust library for generating tripcodes on imageboards and textboards.

Compatibility

This crate is compatible with tripcodes of the following formats:

  • 4chan's normal (non-secure) tripcode
  • 2channel's tripcodes:
    • 10-character tripcode (10桁トリップ)
    • Nama key tripcode (生キートリップ)
    • 12-character tripcode (12桁トリップ)
  • 2ch.sc's tripcodes:
    • 15-character tripcode (15桁トリップ)
    • Katakana tripcode (カタカナトリップ)

Usage

To use this crate, add the following to your project's Cargo.toml:

[dependencies]
tripcode = "0.2"

and this to your crate root:

extern crate tripcode;

Examples

use tripcode::*;

let mut tripcode;

// 4chan's tripcode.
tripcode = Fourchan::generate(&"password");
assert_eq!("ozOtJW9BFA", &tripcode);

// 2channel (Monazilla)'s tripcode. This function automatically selects the proper hashing algorithm.
tripcode = Mona::generate(&"7 bytes");
assert_eq!("W/RvZlE2K.", &tripcode);
tripcode = Mona::generate(&"twelve bytes");
assert_eq!("t+lnR7LBqNQY", &tripcode);
tripcode = Mona::generate(&"#1145145554560721..");
assert_eq!("14cvFmVHg2", &tripcode);

// 2channel's 10-character tripcode (10桁トリップ).
tripcode = Mona10::generate(&"password longer than 12 bytes");
assert_eq!("ozOtJW9BFA", &tripcode);

// 2channel's nama key tripcode (生キートリップ).
// This generator is failable so we use `try_generate()` method, which yields an `Option<String>`.
tripcode = MonaRaw::try_generate(&"#0123456789ABCDEF./").unwrap();
assert_eq!(&"IP9Lda5FPc", &tripcode);

// 2channel's 12-character tripcode (12桁トリップ).
tripcode = Mona12::generate(&"<12 bytes");
assert_eq!("/9L00Vb1PBcb", &tripcode);

tripcode command

This crate also provides a simple command line utility for generating tripcodes.

To install the command, run this in your shell:

cargo install tripcode

The command can take passwords either from arguments:

$ tripcode a b c
ZnBI2EKkq.
taAZ7oPCCM
wG1CV58ydQ

or from stdin (separated by newlines):

$ echo -e 'd\ne\nf' | tripcode -f
taZqHR8ods
xKvzozvsSk
bb6OCCHf8E

The command works with non-UTF-8 encodings as well:

$ echo トリップ | iconv -t sjis | tripcode -f
XSSH/ryx32

The command defaults to generate 4chan's tripcodes. You can generate 2channel's tripcodes by using --type=2ch option.

Internationalization

i18n is provided via gettext, optionally.

To build with it:

cd bin
cargo i18n
cargo build --release --features=i18n

Note: Requires cargo-i18n with 9e86a65 applied.

It increases the size of the binary not too much:

$ cargo build --release
…
$ ls -alh target/release/tripcode-cli
-rwxrwxr-x 2 fred fred 4.0M Sep 19 13:00 target/release/tripcode-cli
$ cargo build --release --features=i18n
…
$ ls -alh target/release/tripcode-cli
-rwxrwxr-x 2 fred fred 6.4M Sep 19 12:52 target/release/tripcode-cli

This can be brought down significantly with --profile=release-lto:

$ cargo build --profile=release-lto
…
$ ls -alh target/release-lto/tripcode-cli
-rwxrwxr-x 2 fred fred 441K Sep 19 13:03 target/release-lto/tripcode-cli
$ cargo build --profile=release-lto --features=i18n
…
$ ls -alh target/release-lto/tripcode-cli
-rwxrwxr-x 2 fred fred 2.3M Sep 19 13:02 target/release-lto/tripcode-cli

tripcodes.rlib's People

Contributors

huton avatar ctrlcctrlv avatar

Watchers

James Cloos avatar  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.