未验证 提交 7ee898ca 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #32931 from jeremyevans/fast-xor

Speed up xor_byte_strings by 70%
......@@ -400,9 +400,14 @@ def per_form_csrf_token(session, action_path, method) # :doc:
end
def xor_byte_strings(s1, s2) # :doc:
s2_bytes = s2.bytes
s1.each_byte.with_index { |c1, i| s2_bytes[i] ^= c1 }
s2_bytes.pack("C*")
s2 = s2.dup
size = s1.bytesize
i = 0
while i < size
s2.setbyte(i, s1.getbyte(i) ^ s2.getbyte(i))
i += 1
end
s2
end
# The form's authenticity parameter. Override to provide your own.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册