1
我有一串二進制數據,並希望選擇一個字符,並^它由0xff。有沒有簡單的方法來做到這一點?例如:紅寶石,二進制字符串XOR隨機字節
x = "test\223\434t"
r = rand(x.length)
c = x[r].unpack("H*")^0xff # This doesnt work
# Re concat the string
我有一串二進制數據,並希望選擇一個字符,並^它由0xff。有沒有簡單的方法來做到這一點?例如:紅寶石,二進制字符串XOR隨機字節
x = "test\223\434t"
r = rand(x.length)
c = x[r].unpack("H*")^0xff # This doesnt work
# Re concat the string
bytes = x.bytes.to_a
# => [116, 101, 115, 116, 147, 28, 116]
bytes[rand(bytes.length)]^0xff
# => 139
有一種簡單的方式來注入焦炭引入字符串? – wuntee 2011-04-20 19:52:08
r = rand(bytes.length); bytes [r] = bytes [r]^0xff; s = bytes.pack(「a *」); – wuntee 2011-04-20 20:12:46