xform
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | xform [2012/07/04 06:30] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | # $EPIC: xform.txt,v 1.10 2012/07/04 06:30:23 jnelson Exp $ | ||
| + | ======Synopsis====== | ||
| + | $[[xform]]("< | ||
| + | |||
| + | ======About string transformations: | ||
| + | The $xform() function transforms the < | ||
| + | three types of transformations: | ||
| + | |||
| + | | Encryption | ||
| + | | Encoding | ||
| + | | Hashing | ||
| + | | Transcoding | Convert a string between different character sets | | ||
| + | |||
| + | Encryption works by taking your plain text and a password key and flipping | ||
| + | some of the bits, which gives you output that looks like random bytes. | ||
| + | The only way to recover the original text is to have the password key. | ||
| + | |||
| + | Because encryption usually gives you binary data, which can't be used | ||
| + | directly in the client, you have to encode it into a usable format. | ||
| + | |||
| + | Both encryption and encoding are symmetric -- they are fully reversable, | ||
| + | and all of the information in the input data is present in the output data, | ||
| + | but in some different way. | ||
| + | |||
| + | Hashing is different. | ||
| + | any input data and removes all but a little bit of the information. | ||
| + | is lossy compression, | ||
| + | way to recover the original text from a hash. | ||
| + | |||
| + | ======Supported Transformations: | ||
| + | The [[xform]] function supports the following encryptions that all take | ||
| + | one required argument. | ||
| + | ^ Name ^ Description | ||
| + | | SED | Simple Encrypted Data | Password | | ||
| + | | BF | Blowfish-CBC | ||
| + | | CAST | CAST5-CBC | ||
| + | | AES | AES256-CBC | ||
| + | | AESSHA | ||
| + | | FISH | Blowfish-ECB | ||
| + | | DEF | Default encryption (not supported yet!) | Password | | ||
| + | |||
| + | The [[xform]] function supports the following encodings that do not take | ||
| + | arguments. | ||
| + | ^ Name ^ Description ^ | ||
| + | | URL | Perform RFC3986 transformation ("URL encoding" | ||
| + | | ENC | Perform Base-16 transformation | | ||
| + | | B64 | Perform RFC1421 transformation ("Base 64") | | ||
| + | | FISH64 | ||
| + | | CTCP | Perform CTCP transformation | | ||
| + | | NONE | No changes (just copies the string) | | ||
| + | | ALL | Return all supported transformations (ignores the text) | | ||
| + | |||
| + | The [[xform]] function supports the following transformations that take one | ||
| + | required argument. | ||
| + | ^ Name ^ Description | ||
| + | | ICONV | Iconv charset transformation | ||
| + | |||
| + | The [[xform]] function supports the folowing digests: | ||
| + | ^ Name ^ Description ^ | ||
| + | | SHA256 | SHA256 Message Digest | | ||
| + | |||
| + | =====Description: | ||
| + | $xform("< | ||
| + | |||
| + | You can string together multiple transformations. | ||
| + | that requires a meta value (ie, a cipherkey) should be supplied after | ||
| + | the transformations **in the correct order**. | ||
| + | plain text. To apply a transformation, | ||
| + | (" | ||
| + | (" | ||
| + | |||
| + | Normally functions do not accept [[what is a word|dwords]] as arguments, | ||
| + | but xform does. If you want to do multiple transformations at once, you | ||
| + | must separate them by spaces and surround the whole thing in double quotes. | ||
| + | If the meta values (ie, passwords for encryption) contain spaces, you must | ||
| + | surround the meta value with double quotes. | ||
| + | |||
| + | ======Iconv transformation: | ||
| + | For the ICONV transformation, | ||
| + | the old encoding and the new encoding separated by a slash ("/" | ||
| + | is no guaranteed list of encodings that you can use, because it depends | ||
| + | on your system' | ||
| + | |||
| + | Example: | ||
| + | $xform(+ICONV " | ||
| + | |||
| + | ======Examples: | ||
| + | ^ If you want to: | ||
| + | | URL-encode a string | ||
| + | | URL-decode a string | ||
| + | | SED-cipher a string | ||
| + | | SED-decipher a string | $xform(-sed password < | ||
| + | | Iconv transform a string from utf-8 to iso-8859-1 | $xform(ICONV " | ||
| + | |||
| + | More practical examples: | ||
| + | -- Read binary data from a file, encrypt it, and url encode it again. | ||
| + | < | ||
| + | @fd = open(file.txt R) | ||
| + | @data = read($fd 1024) | ||
| + | @cipher = xform(" | ||
| + | @close($fd) | ||
| + | msg someone $cipher | ||
| + | </ | ||
| + | |||
| + | Why does this work? | ||
| + | -- $read() returns ctcp-enquoted data, so -CTCP removes it | ||
| + | -- Now we have binary data, so +SED will cipher it | ||
| + | -- Now we have ciphertext, so +URL will url encode it. | ||
| + | |||
| + | We can send this to someone else, and they can put it in $cipher... | ||
| + | < | ||
| + | @newfd = open(newfile.txt W) | ||
| + | @newdata = xform(" | ||
| + | @writeb($newfd $newdata) | ||
| + | @close($newfd) | ||
| + | </ | ||
| + | |||
| + | We did the reverse of the above: | ||
| + | -- We -URL to recover the binary data | ||
| + | -- We -SED to decrypt it using the password | ||
| + | -- We +CTCP to put it in a form we can use with $writeb(). | ||
| + | |||
| + | Viola! | ||
| + | |||
xform.txt · Last modified: 2012/07/04 06:30 by 127.0.0.1
