That said, we don't always have total control over all the systems we must interact with. Maybe you as supporting or tying into some legacy app that used cfusion_encrypt, and you need a way to decrypt. Maybe you're doing so from some other language, like Ruby. I have a present for you. Here is a ruby implementation of cfusion_decrypt. Just promise to use these powers only for good.
def cfusion_decrypt(encrypted, key)
padded_key = ""
encrypted.length.times do |i|
padded_key += key[i % key.length]
end
acc = ""
0.step(encrypted.length-2, 2) do |i|
e_hex = encrypted[i, 2].hex
key_ascii = padded_key[i/2].ord
acc += (e_hex ^ key_ascii).chr
end
acc
end
No comments:
Post a Comment