diff --git a/examples/steganography/css/example.css b/examples/steganography/css/example.css new file mode 100644 index 00000000..64d172ec --- /dev/null +++ b/examples/steganography/css/example.css @@ -0,0 +1,17 @@ +body { + margin: 0; +} +table { + border-spacing: 8px; +} +td { + padding: 0; + border-collapse: collapse; + font-family: Lucida Grande, Segoe UI, DejaVu Sans, Lucida Sans Unicode, Helvetica, Arial, sans-serif; + font-size: 12px; + vertical-align: top; + //background: red; +} +td:first-child { + width: 320px; +} \ No newline at end of file diff --git a/examples/steganography/index.html b/examples/steganography/index.html new file mode 100644 index 00000000..5315f7ba --- /dev/null +++ b/examples/steganography/index.html @@ -0,0 +1,13 @@ + + + + Steganograpy + + + + + + + + + \ No newline at end of file diff --git a/examples/steganography/js/example.js b/examples/steganography/js/example.js new file mode 100644 index 00000000..2f6c5227 --- /dev/null +++ b/examples/steganography/js/example.js @@ -0,0 +1,97 @@ +'use strict'; + +Ox.load('Image', function() { + + var $body = Ox.$('body'), + $table = Ox.$('').appendTo($body), + $tr, + text = { + iceland: 'The first image he told me about ' + + 'was of three children on a road in Iceland in 1965.', + vietnam: 'He said for him it was the image of happiness, ' + + 'and that he had often tried to link it to other images, ' + + 'but it had never worked.' + }, + i = 0; + + encode(decode); + + function encode(callback) { + status('Load iceland.png'); + Ox.Image('png/iceland.png', function(iceland) { + result(Ox.$('').attr({src: iceland.src()})); + status( + 'Encode the text "' + text.iceland + '" into ' + + 'the least significant bits of iceland.png' + ); + iceland.encode(text.iceland, false, 1, function(iceland) { + result(Ox.$('').attr({src: iceland.src()})); + status('Load vietnam.png'); + Ox.Image('png/vietnam.png', function(vietnam) { + result(Ox.$('').attr({src: vietnam.src()})); + status( + 'Encode the text "' + text.vietnam + '" into' + + ' the least significant bits of vietnam.png' + ); + vietnam.encode(text.vietnam, false, 1, function(vietnam) { + result(Ox.$('').attr({src: vietnam.src()})); + status( + 'Encode vietnam.png into iceland.png ' + + 'by flipping the second least significant bits' + ); + iceland.encode(vietnam.src(), -1, function(iceland) { + result(Ox.$('').attr({src: iceland.src()})); + callback(iceland); + }); + }); + }); + }); + }); + } + + function decode(iceland) { + status('Decode the least signigicant bits of iceland.png'); + iceland.decode(false, 1, function(str) { + result(str); + status('Decode all bits of iceland.png'); + iceland.decode(-1, function(src) { + result( + Ox.sub(src, 0, 32) + ' ... [' + + Ox.formatNumber(src.length - 64) + + ' more bytes] ... ' + Ox.sub(src, -32) + ); + status('Load as vietnam.png'); + Ox.Image(src, function(image) { + result(Ox.$('').attr({src: src})); + status('Decode the least significant bits of vietnam.png'); + image.decode(false, 1, function(str) { + result(str); + }); + }); + }); + }); + } + + function status(value) { + var $td = Ox.$('').append($td).appendTo($table); + } + + function result(value) { + var $td = Ox.$('
'); + if (Ox.isString(value)) { + $td.html( + value.replace(/(\w+\.png)/g, '$1') + ); + } else { + $td.append(value); + } + $tr = Ox.$('
'); + if (Ox.isString(value)) { + $td.html(value); + } else { + $td.append(value); + } + $tr.append($td) + } + +}); \ No newline at end of file diff --git a/examples/steganography/png/iceland.png b/examples/steganography/png/iceland.png new file mode 100644 index 00000000..414ae86a Binary files /dev/null and b/examples/steganography/png/iceland.png differ diff --git a/examples/steganography/png/vietnam.png b/examples/steganography/png/vietnam.png new file mode 100644 index 00000000..7c68cb39 Binary files /dev/null and b/examples/steganography/png/vietnam.png differ