1
0
Fork 0
forked from 0x2620/oxjs

update examples

This commit is contained in:
rolux 2012-06-25 11:28:55 +02:00
commit 679dc34dfa
3 changed files with 29 additions and 34 deletions

View file

@ -1,19 +1,16 @@
/*
Ox.Image provides a pair of methods, <code>encode</code> and
<code>decode</code>, which can be used for
<a href="http://en.wikipedia.org/wiki/Steganography">steganography</a>, i.e. to
add a hidden message to an image.<br><br>
The signature of the <code>encode</code> function is
<code>image.encode(message, deflate, mode, callback)</code>.
<code>deflate</code> turns deflate-compression on or off, and <code>mode</code>
determines which bits of the image the message will be written to &mdash; but
for most purposes, the default values (<code>true</code> and <code>0</code>)
are fine, so <code>deflate</code> and <code>mode</code> can be omitted.<br>
<br>
In this example, we demonstrate a valid use case for <code>deflate</code> and
<code>mode</code>: To encode an decoy message (a line of text), which will be
relatively easy to detect, and then the the actual message, (another image,
itself containing another line of text), which will be harder to detect.
Ox.Image provides a pair of methods, `encode` and `decode`, which can be used
for <a href="http://en.wikipedia.org/wiki/Steganography">steganography</a>, i.e.
to add a hidden message to an image.<br><br> The signature of the `encode`
function is `image.encode(message, deflate, mode, callback)`. `deflate` turns
deflate-compression on or off, and `mode` determines which bits of the image the
message will be written to &mdash; but for most purposes, the default values
(`true` and `0`) are fine, so `deflate` and `mode` can be omitted.
In this example, we demonstrate a valid use case for `deflate` and `mode`: To
encode an decoy message (a line of text), which will be relatively easy to
detect, and then the the actual message, (another image, itself containing
another line of text), which will be harder to detect.
*/
'use strict';
@ -33,14 +30,14 @@ Ox.load('Image', function() {
/*
So we first encode two lines text into two images, by writing them bit by
bit (without compression, <code>deflate = false</code>), into the least
significant bit of each 8-bit RGB value (<code>mode = 1</code>). Then we
encode one image into the other: We take the (deflate-compressed,
<code>deflate = true</code>) data URL of the source image and flip, if
needed, the second least significant bit of each RGB value of the target
image, so that the number of bits set to 1, modulo 2 (for example: 10101010
-&gt; 0), is the bit we're encoding (<code>mode = -1</code>). As the least
significant bit remains untouched, this will preserve the encoded text.
bit (without compression, `deflate = false`), into the least significant bit
of each 8-bit RGB value (`mode = 1`). Then we encode one image into the
other: We take the (deflate-compressed, `deflate = true`) data URL of the
source image and flip, if needed, the second least significant bit of each
RGB value of the target image, so that the number of bits set to 1, modulo 2
(for example: 10101010 -> 0), is the bit we're encoding (`mode = -1`). As
the least significant bit remains untouched, this will preserve the encoded
text.
*/
function encode(callback) {
status('Load iceland.png');