WITH RECURSIVE
unhex(str, val, weight) AS (
SELECT 'deadbeef', 0, 1
UNION ALL
SELECT
substr(str, 1, length(str) - 1),
val + (instr('0123456789abcdef', substr(str, length(str), 1)) - 1) * weight,
weight * 16
FROM unhex WHERE length(str) > 0
)
SELECT val FROM unhex order by weight desc limit 1;
然后我把它修改成同样的反字节顺序:
WITH RECURSIVE unhex(str, val, weight) AS (
SELECT
'efbeadde', 0, 1
UNION ALL
SELECT
substr(str, 3),
val + (instr('0123456789abcdef', substr(str, 2, 1)) - 1) * weight + (instr('0123456789abcdef', substr(str, 1, 1)) - 1) * weight * 16,
weight * 256
FROM unhex WHERE length(str) > 0
)
SELECT val FROM unhex order by weight desc limit 1;
1条答案
按热度按时间hyrbngr71#
我找到了正常字节顺序here的答案:
然后我把它修改成同样的反字节顺序: