{"id":470,"date":"2007-07-31T21:11:59","date_gmt":"2007-07-31T20:11:59","guid":{"rendered":"http:\/\/www.branedy.net\/?p=470"},"modified":"2007-08-17T13:27:56","modified_gmt":"2007-08-17T12:27:56","slug":"crypto-in-the-personal-privacy-world","status":"publish","type":"post","link":"https:\/\/www.branedy.net\/?p=470","title":{"rendered":"Crypto in the personal privacy world"},"content":{"rendered":"<p>I was recently presented with <a href=\"http:\/\/www.simonsingh.net\/The_Code_Book.html\">The Code Book<\/a> and while leafing through the pages during a moment of boredom I managed to create a simple crypto using the Julius Caesar character substitution method using Sybase T-SQL. And though I&#8217;m sure that the resulting encrypted text could be broken with brute force, it would not be easy, nor very worthwhile for most messaging. <\/p>\n<p>In this world of spying and privacy invasion from all directions, a little personal crypto might be in order, <a href=\"http:\/\/mediafilter.org\/caq\/cryptogate\/\">particularly if one is inclined to be suspicious  of commercial algorithms<\/a>. and while this stored procedure is simple, it can be enhanced, feel free to use it for your own needs.<\/p>\n<p>CREATE PROCEDURE dbo.simple_crypto<br \/>\n(<br \/>\n   @key_word varchar(25),<br \/>\n   @message varchar(255),<br \/>\n   @direction varchar(8)<br \/>\n)<br \/>\nas<\/p>\n<p>set nocount on<\/p>\n<p>declare<br \/>\n\t\t@key_input varchar(20),<br \/>\n\t\t@key varchar(27),<br \/>\n\t\t@key2 char(27),<br \/>\n\t\t@olumn int, @olumnk int,<br \/>\n\t\t@input varchar(255),<br \/>\n\t\t@olumnb int,<br \/>\n\t\t@output varchar(255),<br \/>\n\t\t@out char(1), @a_char char(1),<br \/>\n\t\t@undone varchar(255),<br \/>\n\t\t@count int<\/p>\n<p>select @count = 97,  @olumnk = 1<br \/>\nselect @key_input = lower(@key_word) &#8211;&#8216;branedy&#8217;<br \/>\nselect @input = lower(@message)<\/p>\n<p>create table #alpha (a_char char(1))<\/p>\n<p>while @count <= 122\nbegin\n\tinsert into #alpha \n\tvalues (char(@count))\n    \n\tselect @count = @count + 1\nend\n\nselect @key = char(32)\n\nwhile @olumnk <= datalength(@key_input)\nbegin\n\tselect @out = substring(@key_input, @olumnk, 1)\n\n\tdelete from #alpha where a_char = @out\n\n\tif @@rowcount = 1\n\tbegin\n\t\t\tselect @key = @key + @out\n\tend\n\n\tselect @olumnk = @olumnk+1\n\nend \n\nselect @key = @key + a_char from #alpha\n\t\ndrop table #alpha\n\nselect \n\t\t@olumn = 1, \n\t\t@olumnb = 1, \n\t\t@key2 = 'abcdefghijklmnopqrstuvwxyz{'\n\n-----------------encrypt\n\nif @direction = 'Cipher'\nbegin\n\nwhile @olumnb <= datalength(@input)\nbegin\n\tselect @output = @output + char(charindex(substring(@input, @olumnb,1), @key) + 96)\n\tselect @olumnb = @olumnb+1\nend \n\nselect @input + ' = ' + @output as 'Encrypted'\n\nend\n-------------------------------------------decrypt\n\nif @direction = 'Decipher'\nbegin\n\nselect @output =@message\n\nwhile @olumn <= datalength(@output)\nbegin\n\tselect \n\t@undone = @undone+ char(ascii(substring(@key, charindex(substring(@output, @olumn,1), @key2),1))) --, \n\tselect @olumn = @olumn+1\nend \n\nselect @output + ' = ' + @undone as 'Decrypted'\nend\n\n--------------------------------\n\nselect 'From the key ' + @key\n\nreturn\nGO\n\n<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>I was recently presented with The Code Book and while leafing through the pages during a moment of boredom I managed to create a simple crypto using the Julius Caesar character substitution method using Sybase T-SQL. And though I&#8217;m sure<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/www.branedy.net\/?p=470\">Read more <span class=\"screen-reader-text\">Crypto in the personal privacy world<\/span><span class=\"meta-nav\"> &#8250;<\/span><\/a><\/div>\n<p><!-- end of .read-more --><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63,48,7,35,8,40,49],"tags":[],"class_list":["post-470","post","type-post","status-publish","format-standard","hentry","category-crypto","category-information","category-internet","category-lifestyle","category-politics","category-privacy","category-world-events"],"_links":{"self":[{"href":"https:\/\/www.branedy.net\/index.php?rest_route=\/wp\/v2\/posts\/470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.branedy.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.branedy.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.branedy.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.branedy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=470"}],"version-history":[{"count":0,"href":"https:\/\/www.branedy.net\/index.php?rest_route=\/wp\/v2\/posts\/470\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.branedy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.branedy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.branedy.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}