Crates.io | tripcode |
lib.rs | tripcode |
version | 0.2.1 |
source | src |
created_at | 2016-09-04 11:43:42.883944 |
updated_at | 2016-10-02 21:20:38.551045 |
description | A library for generating tripcodes on imageboards and textboards. |
homepage | |
repository | https://github.com/huton/tripcode-rs |
max_upload_size | |
id | 6233 |
size | 146,670 |
A Rust library for generating tripcodes on imageboards and textboards.
This crate is compatible with tripcodes of the following formats:
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;
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
commandThis 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.