Skip to content

Instantly share code, notes, and snippets.

@ttdonovan
Created June 21, 2011 22:45
Show Gist options
  • Save ttdonovan/1039144 to your computer and use it in GitHub Desktop.
Save ttdonovan/1039144 to your computer and use it in GitHub Desktop.
Ruby and ActionScript RC4
# Ruby Console
>> data = "super_secret_data"
=> "super_secret_data"
>> rc4_smp = RC4.new('1234567890')
>> rc4_ens = RC4.new('1234567890') # ActionScript something like? ARC4('49505152535455565748') key:ByteArray
>> enc = rc4_smp.encrypt(data)
=> "\xB9Y\x85d*\x05a$\xA7\xFB|\x1DW\xD5\xBAUq"
>> dec = rc4_ens.decrypt(enc)
=> "super_secret_data"
# Ensemble ActionScript
Input string: super_secret_data
Encrypted string: -–’´q‰±Þ
¬µ6TŠI0
Decrypted string: super_secret_data
# Comparing S between rc4_smp and rc4_ens (ARC4('49505152535455565748'))
# rc4_smp S console
[159, 71, 152, 208, 43, 68, 44, 192, 109, 21, 1, 136, 90, 45, 193, 22, 124, 69, 189, 211, 24, 95, 168, 123, 60, 167, 220, 241, 132, 209, 32, 184, 194, 25, 36, 78, 39, 149, 166, 41, 102, 233, 38, 165, 129, 73, 96, 8, 126, 146, 66, 249, 201, 215, 121, 15, 107, 197, 150, 17, 76, 34, 81, 226, 35, 75, 183, 253, 160, 177, 234, 133, 49, 114, 224, 85, 163, 218, 11, 5, 104, 65, 138, 16, 74, 13, 48, 103, 219, 6, 227, 2, 142, 185, 250, 151, 174, 64, 98, 137, 88, 20, 116, 235, 122, 147, 216, 108, 86, 244, 118, 33, 63, 162, 203, 204, 157, 7, 52, 228, 252, 80, 187, 125, 37, 111, 106, 172, 236, 207, 130, 83, 134, 156, 176, 181, 206, 101, 28, 155, 229, 175, 112, 55, 10, 213, 180, 239, 143, 251, 30, 53, 245, 198, 212, 231, 89, 92, 154, 72, 171, 210, 246, 230, 205, 9, 225, 61, 135, 232, 12, 29, 141, 87, 243, 200, 115, 186, 93, 190, 158, 19, 188, 67, 113, 170, 105, 148, 127, 144, 3, 82, 139, 18, 57, 222, 255, 26, 195, 145, 120, 84, 169, 77, 202, 94, 173, 237, 247, 221, 214, 131, 153, 91, 31, 62, 99, 58, 223, 240, 217, 23, 70, 110, 117, 178, 191, 42, 179, 248, 161, 238, 242, 4, 128, 119, 56, 59, 46, 27, 140, 254, 79, 14, 100, 50, 164, 199, 40, 51, 196, 182, 97, 0, 47, 54]
# rc4_ens S (Flex IDE?)
[20, 120, 37, 66, 70, 242, 44, 11, 9, 25, 50, 55, 100, 182, 36, 135, 176, 83, 194, 23, 116, 229, 48, 165, 6, 78, 16, 75, 208, 101, 156, 144, 190, 239, 97, 219, 62, 71, 14, 235, 64, 143, 216, 15, 77, 111, 42, 103, 40, 92, 94, 158, 188, 129, 149, 87, 139, 161, 114, 181, 203, 115, 54, 107, 205, 68, 195, 166, 59, 206, 5, 244, 51, 223, 197, 93, 18, 236, 189, 84, 2, 142, 98, 148, 35, 0, 138, 133, 230, 79, 45, 132, 82, 201, 122, 43, 226, 4, 47, 253, 104, 155, 81, 72, 237, 191, 119, 183, 34, 121, 245, 146, 238, 117, 118, 13, 96, 177, 33, 249, 186, 220, 58, 134, 85, 89, 200, 173, 174, 147, 102, 215, 150, 162, 255, 252, 29, 137, 187, 243, 151, 209, 212, 233, 204, 113, 152, 90, 49, 198, 26, 3, 95, 12, 163, 86, 153, 136, 160, 65, 145, 19, 175, 123, 60, 159, 221, 234, 210, 213, 172, 180, 67, 227, 10, 240, 24, 247, 73, 251, 248, 231, 88, 157, 184, 246, 207, 61, 63, 91, 22, 225, 167, 99, 56, 199, 41, 32, 8, 224, 110, 74, 170, 211, 202, 124, 141, 154, 128, 196, 214, 46, 254, 169, 17, 193, 7, 38, 228, 250, 179, 80, 218, 30, 53, 127, 28, 109, 232, 217, 112, 125, 192, 222, 105, 57, 39, 178, 140, 1, 241, 31, 27, 52, 171, 106, 108, 69, 185, 126, 168, 131, 21, 76, 164, 130]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment