Here’s some more silly applescript “encryption” code. This should really be considered more of a fancy encoding than any kind of encryption, since the security of this is near worthless. Nonetheless, it’s interesting to play with.
property pie : {"14", "41", "15", "59", "92", "26", "65", "53", "35", "58", "89", "97", "79", "93", "32", "23", "38", "84", "46", "62", "26", "64", "43", "33", "38", "83", "32", "27", "79", "95", "50", "02", "28", "88", "84", "41", "19", "97", "71", "16", "69", "93", "39", "99", "93", "37", "75", "51", "10", "05", "58", "82", "20", "09", "97", "74", "49", "94", "44", "45", "59", "92", "23", "30", "07", "78", "81", "16", "64", "40", "06", "62", "28", "86", "62", "20", "08", "89", "99", "98", "86", "62", "28", "80", "03", "34", "48", "82", "25", "53", "34", "42", "21", "11", "17", "70", "06", "67", "79", "98", "82", "21", "14", "48", "80", "08", "86", "65", "51", "13", "32", "28", "82", "23", "30", "06", "66", "64", "47", "70", "09", "93", "38", "84", "44", "46", "60", "09", "95", "55", "50", "05", "58", "82", "22", "23", "31", "17", "72", "25", "53", "35", "59", "94", "40", "08", "81", "12", "28", "84", "48", "81", "11", "11", "17", "74", "45", "50", "02", "28", "84", "41", "10", "02", "27", "70", "01", "19", "93", "38", "85", "52", "21", "11", "10", "05", "55", "55", "59", "96", "64", "44", "46", "62", "22", "29", "94", "48", "89", "95", "54", "49", "93", "30", "03", "38", "81", "19", "96", "64", "44", "42", "28", "88", "81", "10", "09", "97", "75", "56", "66", "65", "59", "93", "33", "34", "44", "46", "61", "12", "28", "84", "47", "75", "56", "64", "48", "82", "23", "33", "37", "78", "86", "67", "78", "83", "31", "16", "65", "52", "27", "71", "12", "20", "01", "19", "90", "09", "91", "14", "45", "56", "64", "48", "85", "56", "66", "69", "92", "23", "34", "46", "60", "03", "34", "48", "86", "61", "10", "04", "45", "54", "43", "32", "26", "66", "64", "48", "82", "21", "13", "33", "39", "93", "36", "60", "07", "72", "26", "60", "02", "24", "49", "91", "14", "41", "12", "27", "73", "37", "72", "24", "45", "58", "87", "70", "42", "06", "66", "60", "06", "63", "31", "15", "55", "58", "88", "81", "17", "74", "48", "88", "81", "15", "52", "20", "09", "92", "20", "09", "96", "62", "28", "82", "29", "92", "25", "54", "40", "09", "91", "17", "71", "15", "53", "36", "64", "43", "36", "67", "78", "89", "92", "25", "59", "90", "03", "36", "60", "42", "01", "11", "13", "33", "30", "05", "53", "30", "05", "54", "48", "88", "82", "20", "04", "46", "66", "65", "52", "21", "13", "38", "84", "41", "14", "46", "69", "95", "51", "19", "94", "41", "15", "51", "11", "16", "60", "09", "94", "43", "33", "30", "05", "57", "72", "27", "70", "03", "36", "65", "57", "75", "59", "95", "59", "91", "19", "95", "53", "30", "09", "92", "21", "18", "86", "61", "11", "17", "73", "38", "81", "19", "93", "32", "26", "61", "11", "17", "79", "93", "31", "10", "05", "51", "11", "18", "85", "54", "48", "80", "07", "74", "44", "46", "62", "23", "37", "79", "99", "96", "62", "27", "74", "49", "95", "56", "67", "73", "35", "51", "18", "88", "85", "57", "75", "52", "27", "72", "24", "48", "89", "91", "12", "22", "27", "79", "93", "38", "81", "18", "83", "30", "01", "11", "19", "94", "49", "91", "12", "29", "98", "83", "33", "36", "67", "73", "33", "36", "62", "24", "44", "40", "06", "65", "56", "66", "64", "43", "30", "08", "86", "60", "02", "21", "13", "39", "94", "49", "94", "46", "63", "39", "95", "52", "22", "24", "47", "73", "37", "71", "19", "90", "07", "70", "02", "21", "17", "79", "98", "86", "60", "09", "94", "43", "37", "70", "02", "27", "77", "70", "05", "53", "39", "92", "21", "17", "71", "17", "76", "62", "29", "93", "31", "17", "76", "67", "75", "52", "23", "38", "84", "46", "67", "74", "48", "81", "18", "84", "46", "67", "76", "66", "69", "94", "40", "05", "51", "13", "32", "20", "42", "42", "05", "56", "68", "81", "12", "27", "71", "14", "45", "52", "26", "63", "35", "56", "60", "08", "82", "27", "77", "78", "85", "57", "77", "71", "13", "34", "42", "27", "75", "57", "77", "78", "89", "96", "60", "09", "91", "17", "73", "36", "63", "37", "71", "17", "78", "87", "72", "21", "14", "46", "68", "84", "44", "40", "09", "90", "01", "12", "22", "24", "49", "95", "53", "34", "43", "30", "01", "14", "46", "65", "54", "49", "95", "58", "85", "53", "37", "71", "10", "05", "50", "07", "79", "92", "22", "27", "79", "96", "68", "89", "92", "25", "58", "89", "92", "23", "35", "54", "42", "20", "01", "19", "99", "95", "56", "61", "11", "12", "21", "12", "29", "90", "02", "21", "19", "96", "60", "08", "86", "64", "40", "03", "34", "44", "41", "18", "81", "15", "59", "98", "81", "13", "36", "62", "29", "97", "77", "74", "47", "77", "71", "13", "30", "09", "99", "96", "60", "05", "51", "18", "87", "70", "07", "72", "21", "11", "13", "34", "49", "99", "99", "99", "99", "99", "98", "83", "37", "72", "29", "97", "78", "80", "04", "49", "99", "95", "51", "10", "05", "59", "97", "73", "31", "17", "73", "32", "28", "81", "16", "60", "09", "96", "63", "31", "18", "85", "59", "95", "50", "02", "24", "44", "45", "59", "94", "45", "55", "53", "34", "46", "69", "90", "08", "83", "30", "02", "26", "64", "42", "25", "52", "22", "23", "30", "08", "82", "25", "53", "33", "34", "44", "46", "68", "85", "50", "03", "35", "52", "26", "61", "19", "93", "31", "11", "18", "88", "81", "17", "71", "10", "01", "10", "42", "42", "03", "31", "13", "37", "78", "83", "38", "87", "75", "52", "28", "88", "86", "65", "58", "87", "75", "53", "33", "32", "20", "08", "83", "38", "81", "14", "42", "20", "06", "61", "17", "71", "17", "77", "76", "66", "69", "91", "14", "47", "73", "30", "03"}
on xor(anInt, anotherInt) (*xor by Michael Miller at http://www.esglabs.com/*)
set int1 to anInt as integer
set int2 to anotherInt as integer
set theResult to 0
set counter to 0
repeat while ((int1 > 0) or (int2 > 0))
set rem1 to int1 mod 2
set rem2 to int2 mod 2
if (rem1 ≠rem2) then
set theResult to theResult + 2 ^ counter
end if
set int1 to int1 div 2
set int2 to int2 div 2
set counter to counter + 1
end repeat
return theResult
end xor
on encrypt(txt, pass)
set txt to txt as text
set strl to count of txt
if strl < 128 then
set padnum to 128 - strl
else if strl > 128 then
set padone to (strl div 128) - 1
set padtwo to padone mod 128
set padnum to padone * 128 + padtwo
else
set padnum to 0
end if
set counter to 0
repeat while counter < padnum
set counter to counter + 1
set txt to txt & (ASCII character 215) as text
end repeat
set strl to count of txt
set charcodes to {}
repeat with i in txt
set charcodes to charcodes & (ASCII number i) as list
end repeat
set xored to {}
set counter to 0
repeat with charcode in charcodes
set counter to counter + 1
set pinum to (item (counter mod 899) of pie) as integer
set xored to xored & (xor(charcode, pinum))
end repeat
set encrypted to {}
set counter to 0
set passcount to count of (pass as text)
repeat with acode in xored
set counter to counter + 1
set currpos to counter mod passcount
if currpos ≠0 then
set currcode to ASCII number (item (counter mod passcount) of pass)
else
set currcode to ASCII number (item -1 of pass)
end if
set encrypted to encrypted & (xor(acode, currcode))
end repeat
set ciphertext to {}
repeat with acode in encrypted
set ciphertext to ciphertext & (ASCII character acode) as text
end repeat
return ciphertext
end encrypt
on decrypt(ciphertext, pass)
set ciphercode to {}
repeat with achar in ciphertext
set ciphercode to ciphercode & (ASCII number achar) as list
end repeat
set decrypted to {}
set counter to 0
set passcount to count of (pass as text)
repeat with acode in ciphercode
set counter to counter + 1
set currpos to counter mod passcount
if currpos ≠0 then
set currcode to ASCII number (item (counter mod passcount) of pass)
else
set currcode to ASCII number (item -1 of pass)
end if
set decrypted to decrypted & (xor(acode, currcode))
end repeat
set unpie to {}
set counter to 0
repeat with charcode in decrypted
set counter to counter + 1
set pinum to (item (counter mod 899) of pie) as integer
set unpie to unpie & (xor(charcode, pinum))
end repeat
set codes to {}
repeat with i in unpie
if i as integer ≠215 then
set codes to codes & i
end if
end repeat
set decoded to {}
repeat with i in codes
set decoded to decoded & (ASCII character i) as text
end repeat
return decoded
end decrypt
encrypt("My name is Ãœmberto, but you can call me Bert :)", "this_is_a_really_boring_password")
(*"78F&bWJ+ÇCS)
Yml[8^/]&H[Q.FQQ6leQofg'rsùÇ∞ǘ™∞”¬Ã±Ã‹Ã âõ°â‰¤â‰ §Ã’Ô¥»Ã±¢âˆ‚â„¢ï¬Ãµ¶Ã¦šÃ¿Ãƒï¬Ã£§Ä±Î©ÃµÃ„â„æÉÜéµâ‰¥¥Ä±¢¸Ã’∆ℴ™âˆÃŠÃ„ÛÛÖ∂õ≤--â„¢¶£¸Ë˜Ã¼Å’ÆÎÇåñô∫"*)
decrypt("78F&bWJ+ÇCS)
Yml[8^/]&H[Q.FQQ6leQofg'rsùÇ∞ǘ™∞”¬Ã±Ã‹Ã âõ°â‰¤â‰ §Ã’Ô¥»Ã±¢âˆ‚â„¢ï¬Ãµ¶Ã¦šÃ¿Ãƒï¬Ã£§Ä±Î©ÃµÃ„â„æÉÜéµâ‰¥¥Ä±¢¸Ã’∆ℴ™âˆÃŠÃ„ÛÛÖ∂õ≤™¶£¸Ë˜Ã¼Å’ÆÎÇåñô∫", "this_is_a_really_boring_password")
(*"My name is Ãœmberto, but you can call me Bert :)"*)
If you have ASCII character 215 in your message, say goodbye to it, because it will disappear in the decrypted result
As has been said before, for real encryption, use the OpenSSL library your system was blessed with (if you’re using OS X). If you have mac classic, use pgp or install macperl and use perl encryption modules.
:Edited to add:Okay, So I was wrong about the last part - turns out that “Blowfish and RC5 algorithms use a 128 bit key.” according to the openssl man page. So, you would have to use a different implementation to take advantage of the full keysize. In the meantime, I recommend AES-256, because, hey, it’s good enough for “top secret” information; it ought to be good enough for anyone else, too.