import{_ as r,c as t,a as e,e as l,w as p,r as D,o as y,b as s,d as n}from"./app-CDdN0tOz.js";const i={};function C(d,a){const o=D("CodeGroupItem"),c=D("CodeGroup");return y(),t("div",null,[a[2]||(a[2]=e('<h1 id="bvid说明" tabindex="-1"><a class="header-anchor" href="#bvid说明"><span>bvid说明</span></a></h1><p>2020-03-23 B站推出了全新的稿件视频id<code>bvid</code>来接替之前的<code>avid</code>，其意义与之相同</p><p>详见：</p><ol><li><a href="https://www.bilibili.com/read/cv5167957" target="_blank" rel="noopener noreferrer">【升级公告】AV号全面升级至BV号（专栏）</a></li><li><a href="https://www.bilibili.com/blackboard/activity-BV-PC.html" target="_blank" rel="noopener noreferrer">【升级公告】AV号全面升级至BV号</a></li></ol><h2 id="概述" tabindex="-1"><a class="header-anchor" href="#概述"><span>概述</span></a></h2><h3 id="格式" tabindex="-1"><a class="header-anchor" href="#格式"><span>格式</span></a></h3><p>“bvid”恒为长度为 12 的字符串，前 3 个固定为“BV1”，后 9 个为 base58 计算结果（不包含数字 <code>0</code> 和大写字母 <code>I</code>、 <code>O</code> 以及小写字母 <code>l</code>）</p><h3 id="实质" tabindex="-1"><a class="header-anchor" href="#实质"><span>实质</span></a></h3><p>“bvid&quot;为“avid”的base58编码，可通过算法进行相互转化</p><h3 id="avid发号方式的变化" tabindex="-1"><a class="header-anchor" href="#avid发号方式的变化"><span>avid发号方式的变化</span></a></h3><p>从 2009-09-09 09:09:09 <a href="https://www.bilibili.com/video/av2" target="_blank" rel="noopener noreferrer">av2</a> 的发布到 2020-03-28 19:45:02 <a href="https://www.bilibili.com/video/av99999999" target="_blank" rel="noopener noreferrer">av99999999</a> 的发布B站结束了以投稿时间为顺序的avid发放，改为随机发放avid</p><p><s>暗示B站东方要完？泪目</s></p><h2 id="算法概述" tabindex="-1"><a class="header-anchor" href="#算法概述"><span>算法概述</span></a></h2><p><s>算法以及程序主要参考<a href="https://www.zhihu.com/question/381784377/answer/1099438784" target="_blank" rel="noopener noreferrer">知乎@mcfx的回答</a></s><s>实际上该算法并不完整,新的算法参考自<a href="https://www.bilibili.com/video/BV1N741127Tj" target="_blank" rel="noopener noreferrer">【揭秘】av号转bv号的过程</a></s> 实际上上面的算法依然不完整，新的算法参考自 <a href="https://github.com/SocialSisterYi/bilibili-API-collect/issues/740" target="_blank" rel="noopener noreferrer">SocialSisterYi#740</a><s>来自 B 站某个 JS 文件？</s></p><h3 id="av-bv算法" tabindex="-1"><a class="header-anchor" href="#av-bv算法"><span>av-&gt;bv算法</span></a></h3><p><strong>说明</strong></p><ol><li>目前的 BV 格式为 BV1XXXXXXXXX，以 BV1 开头，后面包含 9 位有效数据。</li><li>AV 最大值为 2⁵¹。</li></ol><p><strong>算法</strong></p><ul><li>定义一个包含初始值为 <code>[&#39;B&#39;, &#39;V&#39;, &#39;1&#39;, &#39;0&#39;, &#39;0&#39;, &#39;0&#39;, &#39;0&#39;, &#39;0&#39;, &#39;0&#39;, &#39;0&#39;, &#39;0&#39;, &#39;0&#39;]</code> 的长度为 12 的数组<code>bytes</code>，用于存储转换后的字符。 <ul><li>定义变量 <code>bv_idx</code> 并初始化为数组 <code>bytes</code> 的最后一个索引。</li><li>将输入的 <code>aid</code> 与 avid 最大值（2⁵¹）进行按位或运算，其结果与常量 <code>XOR_CODE</code>（23442827791579）进行异或运算，得到变量 <code>tmp</code>。</li><li>当 <code>tmp</code> 大于0时，循环执行以下操作直到小于0： <ul><li>将 <code>tmp</code> 除以 58（码表的长度） 的余数作为索引，从 <code>FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf</code> 码表中取出对应的字符，并将其赋值给 <code>bytes[bv_idx]</code>。</li><li>将 <code>tmp</code> 与 58 求模赋值给 <code>tmp</code>。</li><li>将 <code>bv_idx</code> 减1。</li></ul></li><li>将 <code>bytes</code> 数组中索引为 3 和 9 的元素进行交换。</li><li>将 <code>bytes</code> 数组中索引为 4 和 7 的元素进行交换。</li><li>将 <code>bytes</code> 数组转换为字符串，并返回结果。</li></ul></li></ul><h3 id="bv-av算法" tabindex="-1"><a class="header-anchor" href="#bv-av算法"><span>bv-&gt;av算法</span></a></h3><p>是 #av-&gt;bv算法 的逆向</p><ul><li>将 <code>bvid</code> 中索引为 3 和 9 的字符进行交换。</li><li>将 <code>bvid</code> 中索引为 4 和 7 的字符进行交换。</li><li>删除 <code>bvid</code> 前3个字符（固定为 BV1）。</li><li>定义变量 <code>tmp</code> 并初始化为 0。</li><li>遍历 <code>bvid</code> 的每个字符，执行以下操作： <ul><li>获取当前字符在 <code>FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf</code> 码表中的索引，并将其赋值给变量 <code>idx</code>。</li><li>将 <code>tmp</code> 乘以常量 58，并加上 <code>idx</code>，最后赋值给 <code>tmp</code>。</li></ul></li><li>将 <code>tmp</code> 与常量 2⁵¹ - 1 进行按位与运算，其结果与常量 <code>XOR_CODE</code>（23442827791579） 进行异或运算，得到最终结果。</li></ul><h2 id="编程实现" tabindex="-1"><a class="header-anchor" href="#编程实现"><span>编程实现</span></a></h2><h3 id="javascript-typescript" tabindex="-1"><a class="header-anchor" href="#javascript-typescript"><span>JavaScript/TypeScript</span></a></h3>',24)),l(c,null,{default:p(()=>[l(o,{title:"JavaScript"},{default:p(()=>a[0]||(a[0]=[s("div",{class:"language-javascript line-numbers-mode","data-highlighter":"shiki","data-ext":"javascript",style:{"background-color":"#1E1E1E",color:"#D4D4D4"}},[s("pre",{class:"shiki dark-plus vp-code"},[s("code",{class:"language-javascript"},[s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," XOR_CODE"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#B5CEA8"}},"23442827791579"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," MASK_CODE"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#B5CEA8"}},"2251799813685247"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," MAX_AID"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#B5CEA8"}},"1"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}}," << "),s("span",{style:{color:"#B5CEA8"}},"51"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," BASE"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#B5CEA8"}},"58"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"}),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," data"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#CE9178"}},"'FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf'"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"}),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"function"),s("span",{style:{color:"#DCDCAA"}}," av2bv"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"aid"),s("span",{style:{color:"#D4D4D4"}},") {")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  const"),s("span",{style:{color:"#4FC1FF"}}," bytes"),s("span",{style:{color:"#D4D4D4"}}," = ["),s("span",{style:{color:"#CE9178"}},"'B'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'V'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'1'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},"];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  let"),s("span",{style:{color:"#9CDCFE"}}," bvIndex"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#9CDCFE"}},"length"),s("span",{style:{color:"#D4D4D4"}}," - "),s("span",{style:{color:"#B5CEA8"}},"1"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  let"),s("span",{style:{color:"#9CDCFE"}}," tmp"),s("span",{style:{color:"#D4D4D4"}}," = ("),s("span",{style:{color:"#4FC1FF"}},"MAX_AID"),s("span",{style:{color:"#D4D4D4"}}," | "),s("span",{style:{color:"#DCDCAA"}},"BigInt"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"aid"),s("span",{style:{color:"#D4D4D4"}},")) ^ "),s("span",{style:{color:"#4FC1FF"}},"XOR_CODE"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#C586C0"}},"  while"),s("span",{style:{color:"#D4D4D4"}}," ("),s("span",{style:{color:"#9CDCFE"}},"tmp"),s("span",{style:{color:"#D4D4D4"}}," > "),s("span",{style:{color:"#B5CEA8"}},"0"),s("span",{style:{color:"#D4D4D4"}},") {")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"    bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#9CDCFE"}},"bvIndex"),s("span",{style:{color:"#D4D4D4"}},"] = "),s("span",{style:{color:"#9CDCFE"}},"data"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#DCDCAA"}},"Number"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"tmp"),s("span",{style:{color:"#D4D4D4"}}," % "),s("span",{style:{color:"#DCDCAA"}},"BigInt"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#4FC1FF"}},"BASE"),s("span",{style:{color:"#D4D4D4"}},"))];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"    tmp"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#9CDCFE"}},"tmp"),s("span",{style:{color:"#D4D4D4"}}," / "),s("span",{style:{color:"#4FC1FF"}},"BASE"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"    bvIndex"),s("span",{style:{color:"#D4D4D4"}}," -= "),s("span",{style:{color:"#B5CEA8"}},"1"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  }")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  ["),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"9"),s("span",{style:{color:"#D4D4D4"}},"]] = ["),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"9"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},"]];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  ["),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"4"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"7"),s("span",{style:{color:"#D4D4D4"}},"]] = ["),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"7"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"4"),s("span",{style:{color:"#D4D4D4"}},"]];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#C586C0"}},"  return"),s("span",{style:{color:"#9CDCFE"}}," bytes"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"join"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#CE9178"}},"''"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"}")]),n(`
`),s("span",{class:"line"}),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"function"),s("span",{style:{color:"#DCDCAA"}}," bv2av"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"bvid"),s("span",{style:{color:"#D4D4D4"}},") {")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  const"),s("span",{style:{color:"#4FC1FF"}}," bvidArr"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#9CDCFE"}},"Array"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"from"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"bvid"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  ["),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"9"),s("span",{style:{color:"#D4D4D4"}},"]] = ["),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"9"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},"]];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  ["),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"4"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"7"),s("span",{style:{color:"#D4D4D4"}},"]] = ["),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"7"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"4"),s("span",{style:{color:"#D4D4D4"}},"]];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"  bvidArr"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"splice"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#B5CEA8"}},"0"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  const"),s("span",{style:{color:"#4FC1FF"}}," tmp"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"reduce"),s("span",{style:{color:"#D4D4D4"}},"(("),s("span",{style:{color:"#9CDCFE"}},"pre"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#9CDCFE"}},"bvidChar"),s("span",{style:{color:"#D4D4D4"}},") "),s("span",{style:{color:"#569CD6"}},"=>"),s("span",{style:{color:"#9CDCFE"}}," pre"),s("span",{style:{color:"#D4D4D4"}}," * "),s("span",{style:{color:"#4FC1FF"}},"BASE"),s("span",{style:{color:"#D4D4D4"}}," + "),s("span",{style:{color:"#DCDCAA"}},"BigInt"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"data"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"indexOf"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"bvidChar"),s("span",{style:{color:"#D4D4D4"}},")), "),s("span",{style:{color:"#B5CEA8"}},"0"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#C586C0"}},"  return"),s("span",{style:{color:"#DCDCAA"}}," Number"),s("span",{style:{color:"#D4D4D4"}},"(("),s("span",{style:{color:"#9CDCFE"}},"tmp"),s("span",{style:{color:"#D4D4D4"}}," & "),s("span",{style:{color:"#4FC1FF"}},"MASK_CODE"),s("span",{style:{color:"#D4D4D4"}},") ^ "),s("span",{style:{color:"#4FC1FF"}},"XOR_CODE"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"}")]),n(`
`),s("span",{class:"line"}),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"console"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"log"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#DCDCAA"}},"av2bv"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#B5CEA8"}},"111298867365120"),s("span",{style:{color:"#D4D4D4"}},"));")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"console"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"log"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#DCDCAA"}},"bv2av"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#CE9178"}},"'BV1L9Uoa9EUx'"),s("span",{style:{color:"#D4D4D4"}},"));")])])]),s("div",{class:"line-numbers","aria-hidden":"true",style:{"counter-reset":"line-number 0"}},[s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"})])],-1)])),_:1,__:[0]}),l(o,{title:"TypeScript"},{default:p(()=>a[1]||(a[1]=[s("div",{class:"language-typescript line-numbers-mode","data-highlighter":"shiki","data-ext":"typescript",style:{"background-color":"#1E1E1E",color:"#D4D4D4"}},[s("pre",{class:"shiki dark-plus vp-code"},[s("code",{class:"language-typescript"},[s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," XOR_CODE"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#B5CEA8"}},"23442827791579"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," MASK_CODE"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#B5CEA8"}},"2251799813685247"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," MAX_AID"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#B5CEA8"}},"1"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}}," << "),s("span",{style:{color:"#B5CEA8"}},"51"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," BASE"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#B5CEA8"}},"58"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"}),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"const"),s("span",{style:{color:"#4FC1FF"}}," data"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#CE9178"}},"'FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf'"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"}),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"function"),s("span",{style:{color:"#DCDCAA"}}," av2bv"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"aid"),s("span",{style:{color:"#D4D4D4"}},": "),s("span",{style:{color:"#4EC9B0"}},"number"),s("span",{style:{color:"#D4D4D4"}},") {")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  const"),s("span",{style:{color:"#4FC1FF"}}," bytes"),s("span",{style:{color:"#D4D4D4"}}," = ["),s("span",{style:{color:"#CE9178"}},"'B'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'V'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'1'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#CE9178"}},"'0'"),s("span",{style:{color:"#D4D4D4"}},"];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  let"),s("span",{style:{color:"#9CDCFE"}}," bvIndex"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#9CDCFE"}},"length"),s("span",{style:{color:"#D4D4D4"}}," - "),s("span",{style:{color:"#B5CEA8"}},"1"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  let"),s("span",{style:{color:"#9CDCFE"}}," tmp"),s("span",{style:{color:"#D4D4D4"}}," = ("),s("span",{style:{color:"#4FC1FF"}},"MAX_AID"),s("span",{style:{color:"#D4D4D4"}}," | "),s("span",{style:{color:"#DCDCAA"}},"BigInt"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"aid"),s("span",{style:{color:"#D4D4D4"}},")) ^ "),s("span",{style:{color:"#4FC1FF"}},"XOR_CODE"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#C586C0"}},"  while"),s("span",{style:{color:"#D4D4D4"}}," ("),s("span",{style:{color:"#9CDCFE"}},"tmp"),s("span",{style:{color:"#D4D4D4"}}," > "),s("span",{style:{color:"#B5CEA8"}},"0"),s("span",{style:{color:"#D4D4D4"}},") {")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"    bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#9CDCFE"}},"bvIndex"),s("span",{style:{color:"#D4D4D4"}},"] = "),s("span",{style:{color:"#9CDCFE"}},"data"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#DCDCAA"}},"Number"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"tmp"),s("span",{style:{color:"#D4D4D4"}}," % "),s("span",{style:{color:"#DCDCAA"}},"BigInt"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#4FC1FF"}},"BASE"),s("span",{style:{color:"#D4D4D4"}},"))];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"    tmp"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#9CDCFE"}},"tmp"),s("span",{style:{color:"#D4D4D4"}}," / "),s("span",{style:{color:"#4FC1FF"}},"BASE"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"    bvIndex"),s("span",{style:{color:"#D4D4D4"}}," -= "),s("span",{style:{color:"#B5CEA8"}},"1"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  }")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  ["),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"9"),s("span",{style:{color:"#D4D4D4"}},"]] = ["),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"9"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},"]];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  ["),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"4"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"7"),s("span",{style:{color:"#D4D4D4"}},"]] = ["),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"7"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bytes"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"4"),s("span",{style:{color:"#D4D4D4"}},"]];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#C586C0"}},"  return"),s("span",{style:{color:"#9CDCFE"}}," bytes"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"join"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#CE9178"}},"''"),s("span",{style:{color:"#D4D4D4"}},") "),s("span",{style:{color:"#C586C0"}},"as"),s("span",{style:{color:"#CE9178"}}," `BV1"),s("span",{style:{color:"#569CD6"}},"${"),s("span",{style:{color:"#4EC9B0"}},"string"),s("span",{style:{color:"#569CD6"}},"}"),s("span",{style:{color:"#CE9178"}},"`"),s("span",{style:{color:"#D4D4D4"}},";")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"}")]),n(`
`),s("span",{class:"line"}),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"function"),s("span",{style:{color:"#DCDCAA"}}," bv2av"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"bvid"),s("span",{style:{color:"#D4D4D4"}},": "),s("span",{style:{color:"#CE9178"}},"`BV1"),s("span",{style:{color:"#569CD6"}},"${"),s("span",{style:{color:"#4EC9B0"}},"string"),s("span",{style:{color:"#569CD6"}},"}"),s("span",{style:{color:"#CE9178"}},"`"),s("span",{style:{color:"#D4D4D4"}},") {")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  const"),s("span",{style:{color:"#4FC1FF"}}," bvidArr"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#9CDCFE"}},"Array"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"from"),s("span",{style:{color:"#D4D4D4"}},"<"),s("span",{style:{color:"#4EC9B0"}},"string"),s("span",{style:{color:"#D4D4D4"}},">("),s("span",{style:{color:"#9CDCFE"}},"bvid"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  ["),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"9"),s("span",{style:{color:"#D4D4D4"}},"]] = ["),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"9"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},"]];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"  ["),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"4"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"7"),s("span",{style:{color:"#D4D4D4"}},"]] = ["),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"7"),s("span",{style:{color:"#D4D4D4"}},"], "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"["),s("span",{style:{color:"#B5CEA8"}},"4"),s("span",{style:{color:"#D4D4D4"}},"]];")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"  bvidArr"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"splice"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#B5CEA8"}},"0"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#B5CEA8"}},"3"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#569CD6"}},"  const"),s("span",{style:{color:"#4FC1FF"}}," tmp"),s("span",{style:{color:"#D4D4D4"}}," = "),s("span",{style:{color:"#9CDCFE"}},"bvidArr"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"reduce"),s("span",{style:{color:"#D4D4D4"}},"(("),s("span",{style:{color:"#9CDCFE"}},"pre"),s("span",{style:{color:"#D4D4D4"}},", "),s("span",{style:{color:"#9CDCFE"}},"bvidChar"),s("span",{style:{color:"#D4D4D4"}},") "),s("span",{style:{color:"#569CD6"}},"=>"),s("span",{style:{color:"#9CDCFE"}}," pre"),s("span",{style:{color:"#D4D4D4"}}," * "),s("span",{style:{color:"#4FC1FF"}},"BASE"),s("span",{style:{color:"#D4D4D4"}}," + "),s("span",{style:{color:"#DCDCAA"}},"BigInt"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"data"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"indexOf"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#9CDCFE"}},"bvidChar"),s("span",{style:{color:"#D4D4D4"}},")), "),s("span",{style:{color:"#B5CEA8"}},"0"),s("span",{style:{color:"#569CD6"}},"n"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#C586C0"}},"  return"),s("span",{style:{color:"#DCDCAA"}}," Number"),s("span",{style:{color:"#D4D4D4"}},"(("),s("span",{style:{color:"#9CDCFE"}},"tmp"),s("span",{style:{color:"#D4D4D4"}}," & "),s("span",{style:{color:"#4FC1FF"}},"MASK_CODE"),s("span",{style:{color:"#D4D4D4"}},") ^ "),s("span",{style:{color:"#4FC1FF"}},"XOR_CODE"),s("span",{style:{color:"#D4D4D4"}},");")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#D4D4D4"}},"}")]),n(`
`),s("span",{class:"line"}),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"console"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"log"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#DCDCAA"}},"av2bv"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#B5CEA8"}},"111298867365120"),s("span",{style:{color:"#D4D4D4"}},"));")]),n(`
`),s("span",{class:"line"},[s("span",{style:{color:"#9CDCFE"}},"console"),s("span",{style:{color:"#D4D4D4"}},"."),s("span",{style:{color:"#DCDCAA"}},"log"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#DCDCAA"}},"bv2av"),s("span",{style:{color:"#D4D4D4"}},"("),s("span",{style:{color:"#CE9178"}},"'BV1L9Uoa9EUx'"),s("span",{style:{color:"#D4D4D4"}},"));")])])]),s("div",{class:"line-numbers","aria-hidden":"true",style:{"counter-reset":"line-number 0"}},[s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"}),s("div",{class:"line-number"})])],-1)])),_:1,__:[1]})]),_:1}),a[3]||(a[3]=e(`<h3 id="python" tabindex="-1"><a class="header-anchor" href="#python"><span>Python</span></a></h3><p>来自：<a href="https://github.com/SocialSisterYi/bilibili-API-collect/issues/847#issuecomment-1807020675" target="_blank" rel="noopener noreferrer">#847</a></p><div class="language-python line-numbers-mode" data-highlighter="shiki" data-ext="python" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-python"><span class="line"><span style="color:#D4D4D4;">XOR_CODE = </span><span style="color:#B5CEA8;">23442827791579</span></span>
<span class="line"><span style="color:#D4D4D4;">MASK_CODE = </span><span style="color:#B5CEA8;">2251799813685247</span></span>
<span class="line"><span style="color:#D4D4D4;">MAX_AID = </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;"> &lt;&lt; </span><span style="color:#B5CEA8;">51</span></span>
<span class="line"><span style="color:#D4D4D4;">ALPHABET = </span><span style="color:#CE9178;">&quot;FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">ENCODE_MAP = </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">5</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">2</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span></span>
<span class="line"><span style="color:#D4D4D4;">DECODE_MAP = </span><span style="color:#4EC9B0;">tuple</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">reversed</span><span style="color:#D4D4D4;">(ENCODE_MAP))</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D4D4D4;">BASE = </span><span style="color:#DCDCAA;">len</span><span style="color:#D4D4D4;">(ALPHABET)</span></span>
<span class="line"><span style="color:#D4D4D4;">PREFIX = </span><span style="color:#CE9178;">&quot;BV1&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">PREFIX_LEN = </span><span style="color:#DCDCAA;">len</span><span style="color:#D4D4D4;">(PREFIX)</span></span>
<span class="line"><span style="color:#D4D4D4;">CODE_LEN = </span><span style="color:#DCDCAA;">len</span><span style="color:#D4D4D4;">(ENCODE_MAP)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">def</span><span style="color:#DCDCAA;"> av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">aid</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">) -&gt; </span><span style="color:#4EC9B0;">str</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#D4D4D4;">    bvid = [</span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">] * </span><span style="color:#B5CEA8;">9</span></span>
<span class="line"><span style="color:#D4D4D4;">    tmp = (MAX_AID | aid) ^ XOR_CODE</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> i </span><span style="color:#C586C0;">in</span><span style="color:#DCDCAA;"> range</span><span style="color:#D4D4D4;">(CODE_LEN):</span></span>
<span class="line"><span style="color:#D4D4D4;">        bvid[ENCODE_MAP[i]] = ALPHABET[tmp % BASE]</span></span>
<span class="line"><span style="color:#D4D4D4;">        tmp //= BASE</span></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#D4D4D4;"> PREFIX + </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">.join(bvid)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">def</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bvid</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">str</span><span style="color:#D4D4D4;">) -&gt; </span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#C586C0;">    assert</span><span style="color:#D4D4D4;"> bvid[:</span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">] == PREFIX</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D4D4D4;">    bvid = bvid[</span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">:]</span></span>
<span class="line"><span style="color:#D4D4D4;">    tmp = </span><span style="color:#B5CEA8;">0</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> i </span><span style="color:#C586C0;">in</span><span style="color:#DCDCAA;"> range</span><span style="color:#D4D4D4;">(CODE_LEN):</span></span>
<span class="line"><span style="color:#D4D4D4;">        idx = ALPHABET.index(bvid[DECODE_MAP[i]])</span></span>
<span class="line"><span style="color:#D4D4D4;">        tmp = tmp * BASE + idx</span></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#D4D4D4;"> (tmp &amp; MASK_CODE) ^ XOR_CODE</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">assert</span><span style="color:#D4D4D4;"> av2bv(</span><span style="color:#B5CEA8;">111298867365120</span><span style="color:#D4D4D4;">) == </span><span style="color:#CE9178;">&quot;BV1L9Uoa9EUx&quot;</span></span>
<span class="line"><span style="color:#C586C0;">assert</span><span style="color:#D4D4D4;"> bv2av(</span><span style="color:#CE9178;">&quot;BV1L9Uoa9EUx&quot;</span><span style="color:#D4D4D4;">) == </span><span style="color:#B5CEA8;">111298867365120</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="rust" tabindex="-1"><a class="header-anchor" href="#rust"><span>Rust</span></a></h3><p>参考 <a href="https://github.com/Colerar/abv/blob/main/src/lib.rs" target="_blank" rel="noopener noreferrer">https://github.com/Colerar/abv/blob/main/src/lib.rs</a></p><h3 id="swift" tabindex="-1"><a class="header-anchor" href="#swift"><span>Swift</span></a></h3><div class="language-swift line-numbers-mode" data-highlighter="shiki" data-ext="swift" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-swift"><span class="line"><span style="color:#569CD6;">fileprivate</span><span style="color:#569CD6;"> let</span><span style="color:#D4D4D4;"> XOR_CODE: </span><span style="color:#4EC9B0;">UInt64</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">23442827791579</span></span>
<span class="line"><span style="color:#569CD6;">fileprivate</span><span style="color:#569CD6;"> let</span><span style="color:#D4D4D4;"> MASK_CODE: </span><span style="color:#4EC9B0;">UInt64</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">2251799813685247</span></span>
<span class="line"><span style="color:#569CD6;">fileprivate</span><span style="color:#569CD6;"> let</span><span style="color:#D4D4D4;"> MAX_AID: </span><span style="color:#4EC9B0;">UInt64</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;"> &lt;&lt; </span><span style="color:#B5CEA8;">51</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">fileprivate</span><span style="color:#569CD6;"> let</span><span style="color:#D4D4D4;"> data: [</span><span style="color:#4EC9B0;">UInt8</span><span style="color:#D4D4D4;">] = [</span><span style="color:#B5CEA8;">70</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">99</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">119</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">65</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">80</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">78</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">75</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">84</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">77</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">117</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">103</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">51</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">71</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">86</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">53</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">76</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">106</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">55</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">69</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">74</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">110</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">72</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">112</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">87</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">115</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">120</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">52</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">116</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">98</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">56</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">104</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">97</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">89</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">101</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">118</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">105</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">113</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">66</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">122</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">54</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">114</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">107</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">67</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">121</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">49</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">50</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">109</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">85</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">83</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">68</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">81</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">88</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">57</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">82</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">100</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">111</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">90</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">102</span><span style="color:#D4D4D4;">]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">fileprivate</span><span style="color:#569CD6;"> let</span><span style="color:#D4D4D4;"> BASE: </span><span style="color:#4EC9B0;">UInt64</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">58</span></span>
<span class="line"><span style="color:#569CD6;">fileprivate</span><span style="color:#569CD6;"> let</span><span style="color:#D4D4D4;"> BV_LEN: </span><span style="color:#4EC9B0;">Int</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">12</span></span>
<span class="line"><span style="color:#569CD6;">fileprivate</span><span style="color:#569CD6;"> let</span><span style="color:#D4D4D4;"> PREFIX: </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;"> = </span><span style="color:#CE9178;">&quot;BV1&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">avid</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">UInt64</span><span style="color:#D4D4D4;">) -&gt; </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">    var</span><span style="color:#D4D4D4;"> bytes: [</span><span style="color:#4EC9B0;">UInt8</span><span style="color:#D4D4D4;">] = [</span><span style="color:#B5CEA8;">66</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">86</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">49</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">]</span></span>
<span class="line"><span style="color:#569CD6;">    var</span><span style="color:#D4D4D4;"> bvIdx = BV_LEN - </span><span style="color:#B5CEA8;">1</span></span>
<span class="line"><span style="color:#569CD6;">    var</span><span style="color:#D4D4D4;"> tmp = (MAX_AID | avid) ^ XOR_CODE</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">    while</span><span style="color:#D4D4D4;"> tmp != </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#D4D4D4;">        bytes[bvIdx] = data[</span><span style="color:#4EC9B0;">Int</span><span style="color:#D4D4D4;">(tmp % BASE)]</span></span>
<span class="line"><span style="color:#D4D4D4;">        tmp /= BASE</span></span>
<span class="line"><span style="color:#D4D4D4;">        bvIdx -= </span><span style="color:#B5CEA8;">1</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D4D4D4;">    bytes.</span><span style="color:#DCDCAA;">swapAt</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">    bytes.</span><span style="color:#DCDCAA;">swapAt</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#4EC9B0;"> String</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">decoding</span><span style="color:#D4D4D4;">: bytes, </span><span style="color:#DCDCAA;">as</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">UTF8</span><span style="color:#D4D4D4;">.</span><span style="color:#569CD6;">self</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">bvid</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;">) -&gt; </span><span style="color:#4EC9B0;">UInt64</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">    let</span><span style="color:#D4D4D4;"> fixedBvid: </span><span style="color:#4EC9B0;">String</span></span>
<span class="line"><span style="color:#C586C0;">    if</span><span style="color:#D4D4D4;"> bvid.</span><span style="color:#DCDCAA;">hasPrefix</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;BV&quot;</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#D4D4D4;">        fixedBvid = bvid</span></span>
<span class="line"><span style="color:#D4D4D4;">    } </span><span style="color:#C586C0;">else</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#D4D4D4;">        fixedBvid = </span><span style="color:#CE9178;">&quot;BV&quot;</span><span style="color:#D4D4D4;"> + bvid</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#569CD6;">    var</span><span style="color:#D4D4D4;"> bvidArray = </span><span style="color:#4EC9B0;">Array</span><span style="color:#D4D4D4;">(fixedBvid.</span><span style="color:#9CDCFE;">utf8</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D4D4D4;">    bvidArray.</span><span style="color:#DCDCAA;">swapAt</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">    bvidArray.</span><span style="color:#DCDCAA;">swapAt</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    let</span><span style="color:#D4D4D4;"> trimmedBvid = </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">decoding</span><span style="color:#D4D4D4;">: bvidArray[</span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">...], </span><span style="color:#DCDCAA;">as</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">UTF8</span><span style="color:#D4D4D4;">.</span><span style="color:#569CD6;">self</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    var</span><span style="color:#D4D4D4;"> tmp: </span><span style="color:#4EC9B0;">UInt64</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> char </span><span style="color:#C586C0;">in</span><span style="color:#D4D4D4;"> trimmedBvid {</span></span>
<span class="line"><span style="color:#C586C0;">        if</span><span style="color:#569CD6;"> let</span><span style="color:#D4D4D4;"> idx = data.</span><span style="color:#DCDCAA;">firstIndex</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">of</span><span style="color:#D4D4D4;">: char.</span><span style="color:#9CDCFE;">utf8</span><span style="color:#D4D4D4;">.</span><span style="color:#9CDCFE;">first</span><span style="color:#D4D4D4;">!) {</span></span>
<span class="line"><span style="color:#D4D4D4;">            tmp = tmp * BASE + </span><span style="color:#4EC9B0;">UInt64</span><span style="color:#D4D4D4;">(idx)</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#D4D4D4;"> (tmp &amp; MASK_CODE) ^ XOR_CODE</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#DCDCAA;">print</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">avid</span><span style="color:#D4D4D4;">: </span><span style="color:#B5CEA8;">111298867365120</span><span style="color:#D4D4D4;">))</span></span>
<span class="line"><span style="color:#DCDCAA;">print</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">bvid</span><span style="color:#D4D4D4;">: </span><span style="color:#CE9178;">&quot;BV1L9Uoa9EUx&quot;</span><span style="color:#D4D4D4;">))</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="java" tabindex="-1"><a class="header-anchor" href="#java"><span>Java</span></a></h3><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-java"><span class="line"><span style="color:#569CD6;">import</span><span style="color:#D4D4D4;"> java.math.BigInteger;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">/**</span></span>
<span class="line"><span style="color:#6A9955;"> * </span><span style="color:#569CD6;">@author</span><span style="color:#6A9955;"> cctyl</span></span>
<span class="line"><span style="color:#6A9955;"> */</span></span>
<span class="line"><span style="color:#569CD6;">public</span><span style="color:#569CD6;"> class</span><span style="color:#4EC9B0;"> AVBVConverter</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> BigInteger</span><span style="color:#9CDCFE;"> XOR_CODE</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">23442827791579L</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> BigInteger</span><span style="color:#9CDCFE;"> MASK_CODE</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">2251799813685247L</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> BigInteger</span><span style="color:#9CDCFE;"> MAX_AID</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#9CDCFE;">ONE</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">shiftLeft</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">51</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> int</span><span style="color:#9CDCFE;"> BASE</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> String</span><span style="color:#9CDCFE;"> DATA</span><span style="color:#D4D4D4;"> = </span><span style="color:#CE9178;">&quot;FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf&quot;</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    public</span><span style="color:#569CD6;"> static</span><span style="color:#4EC9B0;"> String</span><span style="color:#DCDCAA;"> av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#4EC9B0;">long</span><span style="color:#9CDCFE;"> aidParam</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#4EC9B0;">        BigInteger</span><span style="color:#9CDCFE;"> aid</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(aidParam);</span></span>
<span class="line"><span style="color:#4EC9B0;">        char</span><span style="color:#D4D4D4;">[] </span><span style="color:#9CDCFE;">bytes</span><span style="color:#D4D4D4;"> = {</span><span style="color:#CE9178;">&#39;B&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;V&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;1&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;0&#39;</span><span style="color:#D4D4D4;">};</span></span>
<span class="line"><span style="color:#4EC9B0;">        int</span><span style="color:#9CDCFE;"> bvIndex</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">bytes</span><span style="color:#D4D4D4;">.</span><span style="color:#9CDCFE;">length</span><span style="color:#D4D4D4;"> - </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#4EC9B0;">        BigInteger</span><span style="color:#9CDCFE;"> tmp</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">MAX_AID</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">or</span><span style="color:#D4D4D4;">(aid).</span><span style="color:#DCDCAA;">xor</span><span style="color:#D4D4D4;">(XOR_CODE);</span></span>
<span class="line"><span style="color:#C586C0;">        while</span><span style="color:#D4D4D4;"> (</span><span style="color:#9CDCFE;">tmp</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">compareTo</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#9CDCFE;">ZERO</span><span style="color:#D4D4D4;">) &gt; </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#D4D4D4;">            bytes[bvIndex] = </span><span style="color:#9CDCFE;">DATA</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">charAt</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">tmp</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">mod</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(BASE)).</span><span style="color:#DCDCAA;">intValue</span><span style="color:#D4D4D4;">());</span></span>
<span class="line"><span style="color:#D4D4D4;">            tmp = </span><span style="color:#9CDCFE;">tmp</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">divide</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(BASE));</span></span>
<span class="line"><span style="color:#D4D4D4;">            bvIndex--;</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#DCDCAA;">        swap</span><span style="color:#D4D4D4;">(bytes, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#DCDCAA;">        swap</span><span style="color:#D4D4D4;">(bytes, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#C586C0;">        return</span><span style="color:#C586C0;"> new</span><span style="color:#DCDCAA;"> String</span><span style="color:#D4D4D4;">(bytes);</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    public</span><span style="color:#569CD6;"> static</span><span style="color:#4EC9B0;"> long</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#4EC9B0;">String</span><span style="color:#9CDCFE;"> bvid</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#4EC9B0;">        char</span><span style="color:#D4D4D4;">[] </span><span style="color:#9CDCFE;">bvidArr</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">bvid</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">toCharArray</span><span style="color:#D4D4D4;">();</span></span>
<span class="line"><span style="color:#DCDCAA;">        swap</span><span style="color:#D4D4D4;">(bvidArr, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#DCDCAA;">        swap</span><span style="color:#D4D4D4;">(bvidArr, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#4EC9B0;">        String</span><span style="color:#9CDCFE;"> adjustedBvid</span><span style="color:#D4D4D4;"> = </span><span style="color:#C586C0;">new</span><span style="color:#DCDCAA;"> String</span><span style="color:#D4D4D4;">(bvidArr, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">bvidArr</span><span style="color:#D4D4D4;">.</span><span style="color:#9CDCFE;">length</span><span style="color:#D4D4D4;"> - </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#4EC9B0;">        BigInteger</span><span style="color:#9CDCFE;"> tmp</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#9CDCFE;">ZERO</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#C586C0;">        for</span><span style="color:#D4D4D4;"> (</span><span style="color:#4EC9B0;">char</span><span style="color:#9CDCFE;"> c</span><span style="color:#C586C0;"> :</span><span style="color:#9CDCFE;"> adjustedBvid</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">toCharArray</span><span style="color:#D4D4D4;">()) {</span></span>
<span class="line"><span style="color:#D4D4D4;">            tmp = </span><span style="color:#9CDCFE;">tmp</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">multiply</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(BASE)).</span><span style="color:#DCDCAA;">add</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">BigInteger</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">DATA</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">indexOf</span><span style="color:#D4D4D4;">(c)));</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#4EC9B0;">        BigInteger</span><span style="color:#9CDCFE;"> xor</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">tmp</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">and</span><span style="color:#D4D4D4;">(MASK_CODE).</span><span style="color:#DCDCAA;">xor</span><span style="color:#D4D4D4;">(XOR_CODE);</span></span>
<span class="line"><span style="color:#C586C0;">        return</span><span style="color:#9CDCFE;"> xor</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">longValue</span><span style="color:#D4D4D4;">();</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#4EC9B0;"> void</span><span style="color:#DCDCAA;"> swap</span><span style="color:#D4D4D4;">(</span><span style="color:#4EC9B0;">char</span><span style="color:#D4D4D4;">[] </span><span style="color:#9CDCFE;">array</span><span style="color:#D4D4D4;">, </span><span style="color:#4EC9B0;">int</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;">, </span><span style="color:#4EC9B0;">int</span><span style="color:#9CDCFE;"> j</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#4EC9B0;">        char</span><span style="color:#9CDCFE;"> temp</span><span style="color:#D4D4D4;"> = array[i];</span></span>
<span class="line"><span style="color:#D4D4D4;">        array[i] = array[j];</span></span>
<span class="line"><span style="color:#D4D4D4;">        array[j] = temp;</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    public</span><span style="color:#569CD6;"> static</span><span style="color:#4EC9B0;"> void</span><span style="color:#DCDCAA;"> main</span><span style="color:#D4D4D4;">(</span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;">[] </span><span style="color:#9CDCFE;">args</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">        final</span><span style="color:#4EC9B0;"> int</span><span style="color:#9CDCFE;"> aid1</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">643755790</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">        final</span><span style="color:#4EC9B0;"> String</span><span style="color:#9CDCFE;"> bv1</span><span style="color:#D4D4D4;"> = </span><span style="color:#CE9178;">&quot;BV1bY4y1j7RA&quot;</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">        final</span><span style="color:#4EC9B0;"> int</span><span style="color:#9CDCFE;"> aid2</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">305988942</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">        final</span><span style="color:#4EC9B0;"> String</span><span style="color:#9CDCFE;"> bv2</span><span style="color:#D4D4D4;"> = </span><span style="color:#CE9178;">&quot;BV1aP411K7it&quot;</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">        //av ==&gt; bv</span></span>
<span class="line"><span style="color:#C586C0;">        assert</span><span style="color:#DCDCAA;"> av2bv</span><span style="color:#D4D4D4;">(aid1).</span><span style="color:#DCDCAA;">equals</span><span style="color:#D4D4D4;">(bv1);</span></span>
<span class="line"><span style="color:#C586C0;">        assert</span><span style="color:#DCDCAA;"> av2bv</span><span style="color:#D4D4D4;">(aid2).</span><span style="color:#DCDCAA;">equals</span><span style="color:#D4D4D4;">(bv2);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">        //bv ==&gt;av</span></span>
<span class="line"><span style="color:#C586C0;">        assert</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(bv1) == aid1;</span></span>
<span class="line"><span style="color:#C586C0;">        assert</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(bv2) == aid2;</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="golang" tabindex="-1"><a class="header-anchor" href="#golang"><span>Golang</span></a></h3><div class="language-go line-numbers-mode" data-highlighter="shiki" data-ext="go" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-go"><span class="line"><span style="color:#569CD6;">package</span><span style="color:#4EC9B0;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">import</span><span style="color:#D4D4D4;"> (</span></span>
<span class="line"><span style="color:#CE9178;">	&quot;fmt&quot;</span></span>
<span class="line"><span style="color:#CE9178;">	&quot;strings&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">var</span><span style="color:#D4D4D4;"> (</span></span>
<span class="line"><span style="color:#9CDCFE;">	XOR_CODE</span><span style="color:#D4D4D4;"> = </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">23442827791579</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">	MAX_CODE</span><span style="color:#D4D4D4;"> = </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">2251799813685247</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">	CHARTS</span><span style="color:#D4D4D4;">   = </span><span style="color:#CE9178;">&quot;FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf&quot;</span></span>
<span class="line"><span style="color:#9CDCFE;">	PAUL_NUM</span><span style="color:#D4D4D4;"> = </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> swapString</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">s</span><span style="color:#4EC9B0;"> string</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">x</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">y</span><span style="color:#4EC9B0;"> int</span><span style="color:#D4D4D4;">) </span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#9CDCFE;">	chars</span><span style="color:#D4D4D4;"> := []</span><span style="color:#4EC9B0;">rune</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">s</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">	chars</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">x</span><span style="color:#D4D4D4;">], </span><span style="color:#9CDCFE;">chars</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">y</span><span style="color:#D4D4D4;">] = </span><span style="color:#9CDCFE;">chars</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">y</span><span style="color:#D4D4D4;">], </span><span style="color:#9CDCFE;">chars</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">x</span><span style="color:#D4D4D4;">]</span></span>
<span class="line"><span style="color:#C586C0;">	return</span><span style="color:#4EC9B0;"> string</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">chars</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> Bvid2Avid</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bvid</span><span style="color:#4EC9B0;"> string</span><span style="color:#D4D4D4;">) (</span><span style="color:#9CDCFE;">avid</span><span style="color:#4EC9B0;"> int64</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#9CDCFE;">	s</span><span style="color:#D4D4D4;"> := </span><span style="color:#DCDCAA;">swapString</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">swapString</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bvid</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">), </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">	bv1</span><span style="color:#D4D4D4;"> := </span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;">([]</span><span style="color:#4EC9B0;">rune</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">s</span><span style="color:#D4D4D4;">)[</span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">:])</span></span>
<span class="line"><span style="color:#9CDCFE;">	temp</span><span style="color:#D4D4D4;"> := </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#C586C0;">	for</span><span style="color:#9CDCFE;"> _</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">c</span><span style="color:#D4D4D4;"> := </span><span style="color:#C586C0;">range</span><span style="color:#9CDCFE;"> bv1</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#9CDCFE;">		idx</span><span style="color:#D4D4D4;"> := </span><span style="color:#9CDCFE;">strings</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">IndexRune</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">CHARTS</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">c</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">		temp</span><span style="color:#D4D4D4;"> = </span><span style="color:#9CDCFE;">temp</span><span style="color:#D4D4D4;">*</span><span style="color:#9CDCFE;">PAUL_NUM</span><span style="color:#D4D4D4;"> + </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">idx</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">	}</span></span>
<span class="line"><span style="color:#9CDCFE;">	avid</span><span style="color:#D4D4D4;"> = (</span><span style="color:#9CDCFE;">temp</span><span style="color:#D4D4D4;"> &amp; </span><span style="color:#9CDCFE;">MAX_CODE</span><span style="color:#D4D4D4;">) ^ </span><span style="color:#9CDCFE;">XOR_CODE</span></span>
<span class="line"><span style="color:#C586C0;">	return</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> Avid2Bvid</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">avid</span><span style="color:#4EC9B0;"> int64</span><span style="color:#D4D4D4;">) (</span><span style="color:#9CDCFE;">bvid</span><span style="color:#4EC9B0;"> string</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#9CDCFE;">	arr</span><span style="color:#D4D4D4;"> := [</span><span style="color:#B5CEA8;">12</span><span style="color:#D4D4D4;">]</span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;">{</span><span style="color:#CE9178;">&quot;B&quot;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&quot;V&quot;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&quot;1&quot;</span><span style="color:#D4D4D4;">}</span></span>
<span class="line"><span style="color:#9CDCFE;">	bvIdx</span><span style="color:#D4D4D4;"> := </span><span style="color:#DCDCAA;">len</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">arr</span><span style="color:#D4D4D4;">) - </span><span style="color:#B5CEA8;">1</span></span>
<span class="line"><span style="color:#9CDCFE;">	temp</span><span style="color:#D4D4D4;"> := (</span><span style="color:#9CDCFE;">avid</span><span style="color:#D4D4D4;"> | (</span><span style="color:#9CDCFE;">MAX_CODE</span><span style="color:#D4D4D4;"> + </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">)) ^ </span><span style="color:#9CDCFE;">XOR_CODE</span></span>
<span class="line"><span style="color:#C586C0;">	for</span><span style="color:#9CDCFE;"> temp</span><span style="color:#D4D4D4;"> &gt; </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#9CDCFE;">		idx</span><span style="color:#D4D4D4;"> := </span><span style="color:#9CDCFE;">temp</span><span style="color:#D4D4D4;"> % </span><span style="color:#9CDCFE;">PAUL_NUM</span></span>
<span class="line"><span style="color:#9CDCFE;">		arr</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">bvIdx</span><span style="color:#D4D4D4;">] = </span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">CHARTS</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">idx</span><span style="color:#D4D4D4;">])</span></span>
<span class="line"><span style="color:#9CDCFE;">		temp</span><span style="color:#D4D4D4;"> /= </span><span style="color:#9CDCFE;">PAUL_NUM</span></span>
<span class="line"><span style="color:#9CDCFE;">		bvIdx</span><span style="color:#D4D4D4;">--</span></span>
<span class="line"><span style="color:#D4D4D4;">	}</span></span>
<span class="line"><span style="color:#9CDCFE;">	raw</span><span style="color:#D4D4D4;"> := </span><span style="color:#9CDCFE;">strings</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">Join</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">arr</span><span style="color:#D4D4D4;">[:], </span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">	bvid</span><span style="color:#D4D4D4;"> = </span><span style="color:#DCDCAA;">swapString</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">swapString</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">raw</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">), </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#C586C0;">	return</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> main</span><span style="color:#D4D4D4;">() {</span></span>
<span class="line"><span style="color:#9CDCFE;">	avid</span><span style="color:#D4D4D4;"> := </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">1054803170</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">	bvid</span><span style="color:#D4D4D4;"> := </span><span style="color:#CE9178;">&quot;BV1mH4y1u7UA&quot;</span></span>
<span class="line"><span style="color:#9CDCFE;">	resAvid</span><span style="color:#D4D4D4;"> := </span><span style="color:#DCDCAA;">Bvid2Avid</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bvid</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">	resBvid</span><span style="color:#D4D4D4;"> := </span><span style="color:#DCDCAA;">Avid2Bvid</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">avid</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#9CDCFE;">	fmt</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">Printf</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;convert bvid to avid: </span><span style="color:#9CDCFE;">%v</span><span style="color:#D7BA7D;">\\t</span><span style="color:#CE9178;">value:</span><span style="color:#9CDCFE;">%v</span><span style="color:#D7BA7D;">\\n</span><span style="color:#CE9178;">&quot;</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">avid</span><span style="color:#D4D4D4;"> == </span><span style="color:#9CDCFE;">resAvid</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">resAvid</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#9CDCFE;">	fmt</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">Printf</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;convert avid to bvid: </span><span style="color:#9CDCFE;">%v</span><span style="color:#D7BA7D;">\\t</span><span style="color:#CE9178;">value:</span><span style="color:#9CDCFE;">%v</span><span style="color:#D7BA7D;">\\n</span><span style="color:#CE9178;">&quot;</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">bvid</span><span style="color:#D4D4D4;"> == </span><span style="color:#9CDCFE;">resBvid</span><span style="color:#D4D4D4;">, </span><span style="color:#9CDCFE;">resBvid</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="c" tabindex="-1"><a class="header-anchor" href="#c"><span>C++</span></a></h3><div class="language-cpp line-numbers-mode" data-highlighter="shiki" data-ext="cpp" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-cpp"><span class="line"><span style="color:#C586C0;">#include</span><span style="color:#CE9178;"> &lt;algorithm&gt;</span></span>
<span class="line"><span style="color:#C586C0;">#include</span><span style="color:#CE9178;"> &lt;cassert&gt;</span></span>
<span class="line"><span style="color:#C586C0;">#include</span><span style="color:#CE9178;"> &lt;print&gt;</span></span>
<span class="line"><span style="color:#C586C0;">#include</span><span style="color:#CE9178;"> &lt;string&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">constexpr</span><span style="color:#569CD6;"> int64_t</span><span style="color:#D4D4D4;"> XOR_CODE          = </span><span style="color:#B5CEA8;">0x1552356C4CDB</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">constexpr</span><span style="color:#569CD6;"> int64_t</span><span style="color:#D4D4D4;"> MAX_AID           = </span><span style="color:#B5CEA8;">0x8000000000000</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">constexpr</span><span style="color:#569CD6;"> int64_t</span><span style="color:#D4D4D4;"> MASK_CODE         = MAX_AID - </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">constexpr</span><span style="color:#569CD6;"> int64_t</span><span style="color:#D4D4D4;"> BASE              = </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">constexpr</span><span style="color:#569CD6;"> char</span><span style="color:#9CDCFE;">    Table</span><span style="color:#D4D4D4;">[BASE + </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">]   = </span><span style="color:#CE9178;">&quot;FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf&quot;</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">constexpr</span><span style="color:#569CD6;"> char</span><span style="color:#9CDCFE;">    ReverseTable</span><span style="color:#D4D4D4;">[</span><span style="color:#B5CEA8;">128</span><span style="color:#D4D4D4;">] = {</span></span>
<span class="line"><span style="color:#B5CEA8;">    0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x2c</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x2d</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x0b</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x1a</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x0e</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x27</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x11</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x1d</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x34</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x03</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x25</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x2a</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x31</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x12</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x0c</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x15</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x13</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x06</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x0f</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x08</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x05</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    0x04</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x32</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x35</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x30</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x07</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x2f</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x0d</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x17</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x33</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x20</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x38</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x1f</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x1c</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x01</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x36</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x21</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x39</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x0a</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x1e</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x23</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x10</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x29</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x2e</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x14</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x37</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    0x16</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x24</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x28</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x18</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x1b</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x09</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x22</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x02</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x19</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x2b</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x26</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0x00</span></span>
<span class="line"><span style="color:#D4D4D4;">};</span></span>
<span class="line"></span>
<span class="line"><span style="color:#4EC9B0;">std</span><span style="color:#D4D4D4;">::</span><span style="color:#4EC9B0;">string</span><span style="color:#DCDCAA;"> Av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#569CD6;">const</span><span style="color:#569CD6;"> int64_t</span><span style="color:#9CDCFE;"> Avid</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#DCDCAA;">    assert</span><span style="color:#D4D4D4;">(Avid &gt; </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;"> &amp;&amp; </span><span style="color:#CE9178;">&quot;Avid must be greater than 0&quot;</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#4EC9B0;">    std</span><span style="color:#D4D4D4;">::string bv = </span><span style="color:#CE9178;">&quot;BV1&quot;</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#9CDCFE;">    bv</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">resize</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">12</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;</span><span style="color:#D7BA7D;">\\0</span><span style="color:#CE9178;">&#39;</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    int64_t</span><span style="color:#D4D4D4;"> tmp = (Avid | MAX_AID) ^ XOR_CODE;</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> (</span><span style="color:#569CD6;">size_t</span><span style="color:#D4D4D4;"> i = </span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">size</span><span style="color:#D4D4D4;">() - </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">; tmp &gt; </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;"> &amp;&amp; i &gt; </span><span style="color:#B5CEA8;">2</span><span style="color:#D4D4D4;">; --i) {</span></span>
<span class="line"><span style="color:#9CDCFE;">        bv</span><span style="color:#D4D4D4;">[i] = </span><span style="color:#9CDCFE;">Table</span><span style="color:#D4D4D4;">[tmp % BASE];</span></span>
<span class="line"><span style="color:#D4D4D4;">        tmp /= BASE;</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#4EC9B0;">    std</span><span style="color:#D4D4D4;">::</span><span style="color:#4EC9B0;">ranges</span><span style="color:#D4D4D4;">::</span><span style="color:#DCDCAA;">swap</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">), </span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">));</span></span>
<span class="line"><span style="color:#4EC9B0;">    std</span><span style="color:#D4D4D4;">::</span><span style="color:#4EC9B0;">ranges</span><span style="color:#D4D4D4;">::</span><span style="color:#DCDCAA;">swap</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">), </span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">));</span></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#D4D4D4;"> bv;</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">int64_t</span><span style="color:#DCDCAA;"> Bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#569CD6;">const</span><span style="color:#4EC9B0;"> std</span><span style="color:#D4D4D4;">::</span><span style="color:#4EC9B0;">string</span><span style="color:#569CD6;"> &amp;</span><span style="color:#9CDCFE;">Bvid</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#DCDCAA;">    assert</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">Bvid</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">starts_with</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;BV1&quot;</span><span style="color:#D4D4D4;">) &amp;&amp; </span><span style="color:#CE9178;">&quot;Bvid must start with &#39;BV1&#39;&quot;</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    auto</span><span style="color:#D4D4D4;"> Bvid_ = Bvid;</span></span>
<span class="line"><span style="color:#4EC9B0;">    std</span><span style="color:#D4D4D4;">::</span><span style="color:#4EC9B0;">ranges</span><span style="color:#D4D4D4;">::</span><span style="color:#DCDCAA;">swap</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">Bvid_</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">), </span><span style="color:#9CDCFE;">Bvid_</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">));</span></span>
<span class="line"><span style="color:#4EC9B0;">    std</span><span style="color:#D4D4D4;">::</span><span style="color:#4EC9B0;">ranges</span><span style="color:#D4D4D4;">::</span><span style="color:#DCDCAA;">swap</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">Bvid_</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">), </span><span style="color:#9CDCFE;">Bvid_</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">));</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    int64_t</span><span style="color:#D4D4D4;"> tmp = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> (</span><span style="color:#569CD6;">int</span><span style="color:#D4D4D4;"> i = </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">; i &lt; </span><span style="color:#9CDCFE;">Bvid_</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">size</span><span style="color:#D4D4D4;">(); ++i) {</span></span>
<span class="line"><span style="color:#D4D4D4;">        tmp = </span><span style="color:#9CDCFE;">ReverseTable</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">Bvid_</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">at</span><span style="color:#D4D4D4;">(i)] + BASE * tmp;</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#D4D4D4;"> (tmp &amp; MASK_CODE) ^ XOR_CODE;</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">int</span><span style="color:#DCDCAA;"> main</span><span style="color:#D4D4D4;">() {</span></span>
<span class="line"><span style="color:#DCDCAA;">    assert</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">Av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">1004871019</span><span style="color:#D4D4D4;">) == </span><span style="color:#CE9178;">&quot;BV16x4y1H7M1&quot;</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#DCDCAA;">    assert</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">Bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;BV16x4y1H7M1&quot;</span><span style="color:#D4D4D4;">) == </span><span style="color:#B5CEA8;">1004871019</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="老版算法存档" tabindex="-1"><a class="header-anchor" href="#老版算法存档"><span>老版算法存档</span></a></h2><p><strong>以下算法已失效</strong>，编解码函数值域有限，不推荐使用，在此仅作为存档</p><details><summary>查看折叠内容：</summary><p>算法参考自<a href="https://www.bilibili.com/video/BV1N741127Tj" target="_blank" rel="noopener noreferrer">【揭秘】av号转bv号的过程</a></p><h3 id="av-bv算法-1" tabindex="-1"><a class="header-anchor" href="#av-bv算法-1"><span>av-&gt;bv算法</span></a></h3><p>注：本算法及示例程序仅能编解码<code>avid &lt; 29460791296</code>，且暂无法验证<code>avid &gt;= 29460791296</code>的正确性 再注：本人不清楚新算法能否编解码<code>avid &gt;= 29460791296</code></p><ol><li>a = (avid ⊕ 177451812) + 100618342136696320</li><li>以 i 为循环变量循环 6 次 b[i] = (a / 58 ^ i) % 58</li><li>将 b[i] 中各个数字转换为以下码表中的字符</li></ol><p>码表：</p><blockquote><p>fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF</p></blockquote><ol start="4"><li><p>初始化字符串 b[i]=<code></code></p></li><li><p>按照以下字符顺序编码表编码并填充至 b[i]</p></li></ol><p>字符顺序编码表：</p><blockquote><p>0 -&gt; 9</p><p>1 -&gt; 8</p><p>2 -&gt; 1</p><p>3 -&gt; 6</p><p>4 -&gt; 2</p><p>5 -&gt; 4</p><p>6 -&gt; 0</p><p>7 -&gt; 7</p><p>8 -&gt; 3</p><p>9 -&gt; 5</p></blockquote><h3 id="bv-av算法-1" tabindex="-1"><a class="header-anchor" href="#bv-av算法-1"><span>bv-&gt;av算法</span></a></h3><p>为以上算法的逆运算</p><h3 id="编程实现-1" tabindex="-1"><a class="header-anchor" href="#编程实现-1"><span>编程实现</span></a></h3><p>使用 Python C TypeScript Java Kotlin Golang Rust 等语言作为示例，欢迎社区提交更多例程</p><h4 id="python-1" tabindex="-1"><a class="header-anchor" href="#python-1"><span>Python</span></a></h4><div class="language-python line-numbers-mode" data-highlighter="shiki" data-ext="python" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-python"><span class="line"><span style="color:#D4D4D4;">XOR = </span><span style="color:#B5CEA8;">177451812</span></span>
<span class="line"><span style="color:#D4D4D4;">ADD = </span><span style="color:#B5CEA8;">100618342136696320</span></span>
<span class="line"><span style="color:#D4D4D4;">TABLE = </span><span style="color:#CE9178;">&quot;fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">MAP = </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">2</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">5</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">def</span><span style="color:#DCDCAA;"> av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">av</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">) -&gt; </span><span style="color:#4EC9B0;">str</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#D4D4D4;">    av = (av ^ XOR) + ADD</span></span>
<span class="line"><span style="color:#D4D4D4;">    bv = [</span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">] * </span><span style="color:#B5CEA8;">10</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> i </span><span style="color:#C586C0;">in</span><span style="color:#DCDCAA;"> range</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">):</span></span>
<span class="line"><span style="color:#D4D4D4;">        bv[MAP[i]] = TABLE[(av // </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">**i) % </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">]</span></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#CE9178;"> &quot;&quot;</span><span style="color:#D4D4D4;">.join(bv)</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">def</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">) -&gt; </span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#D4D4D4;">    av = [</span><span style="color:#CE9178;">&quot;&quot;</span><span style="color:#D4D4D4;">] * </span><span style="color:#B5CEA8;">10</span></span>
<span class="line"><span style="color:#D4D4D4;">    s = </span><span style="color:#B5CEA8;">0</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> i </span><span style="color:#C586C0;">in</span><span style="color:#DCDCAA;"> range</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">):</span></span>
<span class="line"><span style="color:#D4D4D4;">        s += TABLE.find(bv[MAP[i]]) * </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">**i</span></span>
<span class="line"><span style="color:#D4D4D4;">    av = (s - ADD) ^ XOR</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#D4D4D4;"> av</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">def</span><span style="color:#DCDCAA;"> main</span><span style="color:#D4D4D4;">():</span></span>
<span class="line"><span style="color:#C586C0;">    while</span><span style="color:#B5CEA8;"> 1</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#D4D4D4;">        mode = </span><span style="color:#DCDCAA;">input</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;1. AV to BV</span><span style="color:#D7BA7D;">\\n</span><span style="color:#CE9178;">2. BV to AV</span><span style="color:#D7BA7D;">\\n</span><span style="color:#CE9178;">3. Exit</span><span style="color:#D7BA7D;">\\n</span><span style="color:#CE9178;">你的选择：&quot;</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#C586C0;">        if</span><span style="color:#D4D4D4;"> mode == </span><span style="color:#CE9178;">&quot;1&quot;</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#DCDCAA;">            print</span><span style="color:#D4D4D4;">(</span><span style="color:#569CD6;">f</span><span style="color:#CE9178;">&quot;BV号是：BV </span><span style="color:#569CD6;">{</span><span style="color:#D4D4D4;">av2bv(</span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">input</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&#39;AV号是：&#39;</span><span style="color:#D4D4D4;">)))</span><span style="color:#569CD6;">}</span><span style="color:#CE9178;">&quot;</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#C586C0;">        elif</span><span style="color:#D4D4D4;"> mode == </span><span style="color:#CE9178;">&quot;2&quot;</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#DCDCAA;">            print</span><span style="color:#D4D4D4;">(</span><span style="color:#569CD6;">f</span><span style="color:#CE9178;">&quot;AV号是：AV </span><span style="color:#569CD6;">{</span><span style="color:#D4D4D4;">bv2av(</span><span style="color:#DCDCAA;">input</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&#39;BV号是：&#39;</span><span style="color:#D4D4D4;">))</span><span style="color:#569CD6;">}</span><span style="color:#CE9178;">&quot;</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#C586C0;">        elif</span><span style="color:#D4D4D4;"> mode == </span><span style="color:#CE9178;">&quot;3&quot;</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#C586C0;">            break</span></span>
<span class="line"><span style="color:#C586C0;">        else</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#DCDCAA;">            print</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;输入错误请重新输入&quot;</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">if</span><span style="color:#9CDCFE;"> __name__</span><span style="color:#D4D4D4;"> == </span><span style="color:#CE9178;">&quot;__main__&quot;</span><span style="color:#D4D4D4;">:</span></span>
<span class="line"><span style="color:#D4D4D4;">    main()</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="c-1" tabindex="-1"><a class="header-anchor" href="#c-1"><span>C</span></a></h4><div class="language-c line-numbers-mode" data-highlighter="shiki" data-ext="c" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-c"><span class="line"><span style="color:#C586C0;">#include</span><span style="color:#CE9178;"> &lt;stdio.h&gt;</span></span>
<span class="line"><span style="color:#C586C0;">#include</span><span style="color:#CE9178;"> &lt;stdlib.h&gt;</span></span>
<span class="line"><span style="color:#C586C0;">#include</span><span style="color:#CE9178;"> &lt;math.h&gt;</span></span>
<span class="line"><span style="color:#C586C0;">#include</span><span style="color:#CE9178;"> &lt;string.h&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#569CD6;"> char</span><span style="color:#D4D4D4;"> table</span><span style="color:#569CD6;">[]</span><span style="color:#D4D4D4;"> = </span><span style="color:#CE9178;">&quot;fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF&quot;</span><span style="color:#D4D4D4;">;</span><span style="color:#6A9955;"> // 码表</span></span>
<span class="line"><span style="color:#569CD6;">char</span><span style="color:#9CDCFE;"> tr</span><span style="color:#D4D4D4;">[</span><span style="color:#B5CEA8;">124</span><span style="color:#D4D4D4;">];</span><span style="color:#6A9955;"> // 反查码表</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#569CD6;"> unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#D4D4D4;"> XOR = </span><span style="color:#B5CEA8;">177451812</span><span style="color:#D4D4D4;">;</span><span style="color:#6A9955;"> // 固定异或值</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#569CD6;"> unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#D4D4D4;"> ADD = </span><span style="color:#B5CEA8;">8728348608</span><span style="color:#D4D4D4;">;</span><span style="color:#6A9955;"> // 固定加法值</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#569CD6;"> int</span><span style="color:#D4D4D4;"> s</span><span style="color:#569CD6;">[]</span><span style="color:#D4D4D4;"> = {</span><span style="color:#B5CEA8;">11</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">};</span><span style="color:#6A9955;"> // 位置编码表</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">// 初始化反查码表</span></span>
<span class="line"><span style="color:#569CD6;">void</span><span style="color:#DCDCAA;"> tr_init</span><span style="color:#D4D4D4;">() {</span></span>
<span class="line"><span style="color:#C586C0;">	for</span><span style="color:#D4D4D4;"> (</span><span style="color:#569CD6;">int</span><span style="color:#D4D4D4;"> i = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; i &lt; </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">; i++)</span></span>
<span class="line"><span style="color:#9CDCFE;">		tr</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">table</span><span style="color:#D4D4D4;">[i]] = i;</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#569CD6;">char</span><span style="color:#9CDCFE;"> bv</span><span style="color:#569CD6;">[]</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#569CD6;">	unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#D4D4D4;"> r = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">	unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#D4D4D4;"> av;</span></span>
<span class="line"><span style="color:#C586C0;">	for</span><span style="color:#D4D4D4;"> (</span><span style="color:#569CD6;">int</span><span style="color:#D4D4D4;"> i = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; i &lt; </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">; i++)</span></span>
<span class="line"><span style="color:#D4D4D4;">		r += </span><span style="color:#9CDCFE;">tr</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">s</span><span style="color:#D4D4D4;">[i]]] * (</span><span style="color:#569CD6;">unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#D4D4D4;">)</span><span style="color:#DCDCAA;">pow</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, i);</span></span>
<span class="line"><span style="color:#D4D4D4;">	av = (r - ADD) ^ XOR;</span></span>
<span class="line"><span style="color:#C586C0;">	return</span><span style="color:#D4D4D4;"> av;</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">char</span><span style="color:#D4D4D4;"> *</span><span style="color:#DCDCAA;">av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#569CD6;">unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#9CDCFE;"> av</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#569CD6;">	char</span><span style="color:#D4D4D4;"> *result = (</span><span style="color:#569CD6;">char</span><span style="color:#D4D4D4;">*)</span><span style="color:#DCDCAA;">malloc</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">13</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#DCDCAA;">	strcpy</span><span style="color:#D4D4D4;">(result,</span><span style="color:#CE9178;">&quot;BV1  4 1 7  &quot;</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#D4D4D4;">	av = (av ^ XOR) + ADD;</span></span>
<span class="line"><span style="color:#C586C0;">	for</span><span style="color:#D4D4D4;"> (</span><span style="color:#569CD6;">int</span><span style="color:#D4D4D4;"> i = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; i &lt; </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">; i++)</span></span>
<span class="line"><span style="color:#9CDCFE;">		result</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">s</span><span style="color:#D4D4D4;">[i]] = </span><span style="color:#9CDCFE;">table</span><span style="color:#D4D4D4;">[(</span><span style="color:#569CD6;">unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#D4D4D4;">)(av / (</span><span style="color:#569CD6;">unsigned</span><span style="color:#569CD6;"> long</span><span style="color:#569CD6;"> long</span><span style="color:#D4D4D4;">)</span><span style="color:#DCDCAA;">pow</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, i)) % </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">];</span></span>
<span class="line"><span style="color:#C586C0;">	return</span><span style="color:#D4D4D4;"> result;</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">int</span><span style="color:#DCDCAA;"> main</span><span style="color:#D4D4D4;">() {</span></span>
<span class="line"><span style="color:#DCDCAA;">	tr_init</span><span style="color:#D4D4D4;">();</span></span>
<span class="line"><span style="color:#DCDCAA;">	printf</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;</span><span style="color:#9CDCFE;">%s</span><span style="color:#D7BA7D;">\\n</span><span style="color:#CE9178;">&quot;</span><span style="color:#D4D4D4;">, </span><span style="color:#DCDCAA;">av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">170001</span><span style="color:#D4D4D4;">));</span></span>
<span class="line"><span style="color:#DCDCAA;">	printf</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;</span><span style="color:#9CDCFE;">%u</span><span style="color:#D7BA7D;">\\n</span><span style="color:#CE9178;">&quot;</span><span style="color:#D4D4D4;">, </span><span style="color:#DCDCAA;">bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;BV17x411w7KC&quot;</span><span style="color:#D4D4D4;">));</span></span>
<span class="line"><span style="color:#C586C0;">	return</span><span style="color:#B5CEA8;"> 0</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>输出为：</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-"><span class="line"><span>BV17x411w7KC</span></span>
<span class="line"><span>170001</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="typescript" tabindex="-1"><a class="header-anchor" href="#typescript"><span>TypeScript</span></a></h4><p>感谢<a href="https://github.com/SocialSisterYi/bilibili-API-collect/issues/417#issuecomment-1186475063" target="_blank" rel="noopener noreferrer">#417</a>提供</p><div class="language-typescript line-numbers-mode" data-highlighter="shiki" data-ext="typescript" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-typescript"><span class="line"><span style="color:#C586C0;">export</span><span style="color:#C586C0;"> default</span><span style="color:#569CD6;"> class</span><span style="color:#4EC9B0;"> BvCode</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">  private</span><span style="color:#9CDCFE;"> TABEL</span><span style="color:#D4D4D4;"> = </span><span style="color:#CE9178;">&#39;fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF&#39;</span><span style="color:#D4D4D4;">; </span><span style="color:#6A9955;">// 码表</span></span>
<span class="line"><span style="color:#569CD6;">  private</span><span style="color:#9CDCFE;"> TR</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">Record</span><span style="color:#D4D4D4;">&lt;</span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;">, </span><span style="color:#4EC9B0;">number</span><span style="color:#D4D4D4;">&gt; = {}; </span><span style="color:#6A9955;">// 反查码表</span></span>
<span class="line"><span style="color:#569CD6;">  private</span><span style="color:#9CDCFE;"> S</span><span style="color:#D4D4D4;"> = [</span><span style="color:#B5CEA8;">11</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">]; </span><span style="color:#6A9955;">// 位置编码表</span></span>
<span class="line"><span style="color:#569CD6;">  private</span><span style="color:#9CDCFE;"> XOR</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">177451812</span><span style="color:#D4D4D4;">; </span><span style="color:#6A9955;">// 固定异或值</span></span>
<span class="line"><span style="color:#569CD6;">  private</span><span style="color:#9CDCFE;"> ADD</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">8728348608</span><span style="color:#D4D4D4;">; </span><span style="color:#6A9955;">// 固定加法值</span></span>
<span class="line"><span style="color:#569CD6;">  constructor</span><span style="color:#D4D4D4;">() {</span></span>
<span class="line"><span style="color:#6A9955;">    // 初始化反查码表</span></span>
<span class="line"><span style="color:#569CD6;">    const</span><span style="color:#4FC1FF;"> len</span><span style="color:#D4D4D4;"> = </span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">TABEL</span><span style="color:#D4D4D4;">.</span><span style="color:#9CDCFE;">length</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> (</span><span style="color:#569CD6;">let</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;"> &lt; </span><span style="color:#9CDCFE;">len</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">++) {</span></span>
<span class="line"><span style="color:#569CD6;">      this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">TR</span><span style="color:#D4D4D4;">[</span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">TABEL</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]] = </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#DCDCAA;">  av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">av</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">number</span><span style="color:#D4D4D4;">): </span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">    const</span><span style="color:#4FC1FF;"> x_</span><span style="color:#D4D4D4;"> = (</span><span style="color:#9CDCFE;">av</span><span style="color:#D4D4D4;"> ^ </span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">XOR</span><span style="color:#D4D4D4;">) + </span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">ADD</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">    const</span><span style="color:#4FC1FF;"> r</span><span style="color:#D4D4D4;"> = [</span><span style="color:#CE9178;">&#39;B&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;V&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;1&#39;</span><span style="color:#D4D4D4;">, , , </span><span style="color:#CE9178;">&#39;4&#39;</span><span style="color:#D4D4D4;">, , </span><span style="color:#CE9178;">&#39;1&#39;</span><span style="color:#D4D4D4;">, , </span><span style="color:#CE9178;">&#39;7&#39;</span><span style="color:#D4D4D4;">];</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> (</span><span style="color:#569CD6;">let</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;"> &lt; </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">++) {</span></span>
<span class="line"><span style="color:#9CDCFE;">      r</span><span style="color:#D4D4D4;">[</span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">S</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]] = </span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">TABEL</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">Math</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">floor</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">x_</span><span style="color:#D4D4D4;"> / </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;"> ** </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">) % </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">];</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#9CDCFE;"> r</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">join</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&#39;&#39;</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#DCDCAA;">  bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;">): </span><span style="color:#4EC9B0;">number</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">    let</span><span style="color:#9CDCFE;"> r</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#D4D4D4;"> (</span><span style="color:#569CD6;">let</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;"> &lt; </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">++) {</span></span>
<span class="line"><span style="color:#9CDCFE;">      r</span><span style="color:#D4D4D4;"> += </span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">TR</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">[</span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">S</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]]] * </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;"> ** </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#C586C0;">    return</span><span style="color:#D4D4D4;"> (</span><span style="color:#9CDCFE;">r</span><span style="color:#D4D4D4;"> - </span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">ADD</span><span style="color:#D4D4D4;">) ^ </span><span style="color:#569CD6;">this</span><span style="color:#D4D4D4;">.</span><span style="color:#4FC1FF;">XOR</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#D4D4D4;">  }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#4FC1FF;"> bvcode</span><span style="color:#D4D4D4;"> = </span><span style="color:#569CD6;">new</span><span style="color:#DCDCAA;"> BvCode</span><span style="color:#D4D4D4;">();</span></span>
<span class="line"></span>
<span class="line"><span style="color:#9CDCFE;">console</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">log</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bvcode</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">170001</span><span style="color:#D4D4D4;">));</span></span>
<span class="line"><span style="color:#9CDCFE;">console</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">log</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bvcode</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&#39;BV17x411w7KC&#39;</span><span style="color:#D4D4D4;">));</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>输出为：</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-"><span class="line"><span>BV17x411w7KC</span></span>
<span class="line"><span>170001</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="java-1" tabindex="-1"><a class="header-anchor" href="#java-1"><span>Java</span></a></h4><div class="language-java line-numbers-mode" data-highlighter="shiki" data-ext="java" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-java"><span class="line"><span style="color:#6A9955;">/**</span></span>
<span class="line"><span style="color:#6A9955;"> * 算法来自：https://www.zhihu.com/question/381784377/answer/1099438784</span></span>
<span class="line"><span style="color:#6A9955;"> */</span></span>
<span class="line"><span style="color:#569CD6;">public</span><span style="color:#569CD6;"> class</span><span style="color:#4EC9B0;"> Util</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> String</span><span style="color:#9CDCFE;"> TABLE</span><span style="color:#D4D4D4;"> = </span><span style="color:#CE9178;">&quot;fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF&quot;</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> int</span><span style="color:#D4D4D4;">[] </span><span style="color:#9CDCFE;">S</span><span style="color:#D4D4D4;"> = </span><span style="color:#C586C0;">new</span><span style="color:#4EC9B0;"> int</span><span style="color:#D4D4D4;">[]{</span><span style="color:#B5CEA8;">11</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">};</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> int</span><span style="color:#9CDCFE;"> XOR</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">177451812</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> long</span><span style="color:#9CDCFE;"> ADD</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">8728348608L</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> static</span><span style="color:#569CD6;"> final</span><span style="color:#4EC9B0;"> Map</span><span style="color:#D4D4D4;">&lt;</span><span style="color:#4EC9B0;">Character</span><span style="color:#D4D4D4;">, </span><span style="color:#4EC9B0;">Integer</span><span style="color:#D4D4D4;">&gt; </span><span style="color:#9CDCFE;">MAP</span><span style="color:#D4D4D4;"> = </span><span style="color:#C586C0;">new</span><span style="color:#4EC9B0;"> HashMap</span><span style="color:#D4D4D4;">&lt;&gt;();</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    static</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#C586C0;">        for</span><span style="color:#D4D4D4;"> (</span><span style="color:#4EC9B0;">int</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; i &lt; </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">; i++) {</span></span>
<span class="line"><span style="color:#9CDCFE;">            MAP</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">put</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">TABLE</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">charAt</span><span style="color:#D4D4D4;">(i), i);</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    public</span><span style="color:#569CD6;"> static</span><span style="color:#4EC9B0;"> String</span><span style="color:#DCDCAA;"> aidToBvid</span><span style="color:#D4D4D4;">(</span><span style="color:#4EC9B0;">int</span><span style="color:#9CDCFE;"> aid</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#4EC9B0;">        long</span><span style="color:#9CDCFE;"> x</span><span style="color:#D4D4D4;"> = (aid ^ XOR) + ADD;</span></span>
<span class="line"><span style="color:#4EC9B0;">        char</span><span style="color:#D4D4D4;">[] </span><span style="color:#9CDCFE;">chars</span><span style="color:#D4D4D4;"> = </span><span style="color:#C586C0;">new</span><span style="color:#4EC9B0;"> char</span><span style="color:#D4D4D4;">[]{</span><span style="color:#CE9178;">&#39;B&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;V&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;1&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39; &#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39; &#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;4&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39; &#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;1&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39; &#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39;7&#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39; &#39;</span><span style="color:#D4D4D4;">, </span><span style="color:#CE9178;">&#39; &#39;</span><span style="color:#D4D4D4;">};</span></span>
<span class="line"><span style="color:#C586C0;">        for</span><span style="color:#D4D4D4;"> (</span><span style="color:#4EC9B0;">int</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; i &lt; </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">; i++) {</span></span>
<span class="line"><span style="color:#4EC9B0;">            int</span><span style="color:#9CDCFE;"> pow</span><span style="color:#D4D4D4;"> = (</span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">) </span><span style="color:#9CDCFE;">Math</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">pow</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, i);</span></span>
<span class="line"><span style="color:#4EC9B0;">            long</span><span style="color:#9CDCFE;"> i1</span><span style="color:#D4D4D4;"> = x / pow;</span></span>
<span class="line"><span style="color:#4EC9B0;">            int</span><span style="color:#9CDCFE;"> index</span><span style="color:#D4D4D4;"> = (</span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">) (i1 % </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">);</span></span>
<span class="line"><span style="color:#D4D4D4;">            chars[</span><span style="color:#4EC9B0;">S</span><span style="color:#D4D4D4;">[i]] = </span><span style="color:#9CDCFE;">TABLE</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">charAt</span><span style="color:#D4D4D4;">(index);</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#C586C0;">        return</span><span style="color:#9CDCFE;"> String</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(chars);</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    public</span><span style="color:#569CD6;"> static</span><span style="color:#4EC9B0;"> int</span><span style="color:#DCDCAA;"> bvidToAid</span><span style="color:#D4D4D4;">(</span><span style="color:#4EC9B0;">String</span><span style="color:#9CDCFE;"> bvid</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#4EC9B0;">        long</span><span style="color:#9CDCFE;"> r</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#C586C0;">        for</span><span style="color:#D4D4D4;"> (</span><span style="color:#4EC9B0;">int</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; i &lt; </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">; i++) {</span></span>
<span class="line"><span style="color:#D4D4D4;">            r += </span><span style="color:#9CDCFE;">MAP</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">get</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bvid</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">charAt</span><span style="color:#D4D4D4;">(</span><span style="color:#4EC9B0;">S</span><span style="color:#D4D4D4;">[i])) * </span><span style="color:#9CDCFE;">Math</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">pow</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, i);</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#C586C0;">        return</span><span style="color:#D4D4D4;"> (</span><span style="color:#4EC9B0;">int</span><span style="color:#D4D4D4;">) ((r - ADD) ^ XOR);</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="kotlin" tabindex="-1"><a class="header-anchor" href="#kotlin"><span>Kotlin</span></a></h4><div class="language-kotlin line-numbers-mode" data-highlighter="shiki" data-ext="kotlin" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-kotlin"><span class="line"><span style="color:#6A9955;">/**</span></span>
<span class="line"><span style="color:#6A9955;"> * 此程序非完全原创，改编自GH站内某大佬的Java程序，修改了部分代码，且转换为Kotlin</span></span>
<span class="line"><span style="color:#6A9955;"> * 算法来源同上</span></span>
<span class="line"><span style="color:#6A9955;"> */</span></span>
<span class="line"><span style="color:#569CD6;">object</span><span style="color:#4EC9B0;"> VideoUtils</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#6A9955;">    //这里是由知乎大佬不知道用什么方法得出的转换用数字</span></span>
<span class="line"><span style="color:#569CD6;">    var</span><span style="color:#D4D4D4;"> ss = </span><span style="color:#DCDCAA;">intArrayOf</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">11</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">2</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">5</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#569CD6;">    var</span><span style="color:#D4D4D4;"> xor: </span><span style="color:#4EC9B0;">Long</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">177451812</span><span style="color:#6A9955;"> //二进制时加减数1</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">    var</span><span style="color:#D4D4D4;"> add = </span><span style="color:#B5CEA8;">8728348608L</span><span style="color:#6A9955;"> //十进制时加减数2</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">    //变量初始化工作，加载哈希表</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> const</span><span style="color:#569CD6;"> val</span><span style="color:#D4D4D4;"> table = </span><span style="color:#CE9178;">&quot;fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF&quot;</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> val</span><span style="color:#D4D4D4;"> mp = </span><span style="color:#DCDCAA;">HashMap</span><span style="color:#D4D4D4;">&lt;</span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;">, </span><span style="color:#4EC9B0;">Int</span><span style="color:#D4D4D4;">&gt;()</span></span>
<span class="line"><span style="color:#569CD6;">    private</span><span style="color:#569CD6;"> val</span><span style="color:#D4D4D4;"> mp2 = </span><span style="color:#DCDCAA;">HashMap</span><span style="color:#D4D4D4;">&lt;</span><span style="color:#4EC9B0;">Int</span><span style="color:#D4D4D4;">, </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;">&gt;()</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">    //现在，定义av号和bv号互转的方法</span></span>
<span class="line"><span style="color:#6A9955;">//定义一个power乘方方法，这是转换进制必要的</span></span>
<span class="line"><span style="color:#569CD6;">    fun</span><span style="color:#DCDCAA;"> power</span><span style="color:#D4D4D4;">(a: </span><span style="color:#4EC9B0;">Int</span><span style="color:#D4D4D4;">, b: </span><span style="color:#4EC9B0;">Int</span><span style="color:#D4D4D4;">): </span><span style="color:#4EC9B0;">Long</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">        var</span><span style="color:#D4D4D4;"> power: </span><span style="color:#4EC9B0;">Long</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">1</span></span>
<span class="line"><span style="color:#C586C0;">        for</span><span style="color:#D4D4D4;"> (c </span><span style="color:#569CD6;">in</span><span style="color:#B5CEA8;"> 0</span><span style="color:#D4D4D4;"> until b) power *= a.</span><span style="color:#DCDCAA;">toLong</span><span style="color:#D4D4D4;">()</span></span>
<span class="line"><span style="color:#C586C0;">        return</span><span style="color:#D4D4D4;"> power</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">    //bv转av方法</span></span>
<span class="line"><span style="color:#569CD6;">    fun</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(s: </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;">): </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">        var</span><span style="color:#D4D4D4;"> r: </span><span style="color:#4EC9B0;">Long</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span></span>
<span class="line"><span style="color:#6A9955;">        //58进制转换</span></span>
<span class="line"><span style="color:#C586C0;">        for</span><span style="color:#D4D4D4;"> (i </span><span style="color:#569CD6;">in</span><span style="color:#B5CEA8;"> 0</span><span style="color:#D4D4D4;">..</span><span style="color:#B5CEA8;">57</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#569CD6;">            val</span><span style="color:#D4D4D4;"> s1 = table.</span><span style="color:#DCDCAA;">substring</span><span style="color:#D4D4D4;">(i, i + </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">            mp[s1] = i</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#C586C0;">        for</span><span style="color:#D4D4D4;"> (i </span><span style="color:#569CD6;">in</span><span style="color:#B5CEA8;"> 0</span><span style="color:#D4D4D4;">..</span><span style="color:#B5CEA8;">5</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#D4D4D4;">            r += mp[s.</span><span style="color:#DCDCAA;">substring</span><span style="color:#D4D4D4;">(ss[i], ss[i] + </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">)]!! * </span><span style="color:#DCDCAA;">power</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, i)</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#6A9955;">        //转换完成后，需要处理，带上两个随机数</span></span>
<span class="line"><span style="color:#C586C0;">        return</span><span style="color:#D4D4D4;"> (r - add xor xor).</span><span style="color:#DCDCAA;">toString</span><span style="color:#D4D4D4;">()</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">    //av转bv方法</span></span>
<span class="line"><span style="color:#569CD6;">    fun</span><span style="color:#DCDCAA;"> av2bv</span><span style="color:#D4D4D4;">(st: </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;">): </span><span style="color:#4EC9B0;">String</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#C586C0;">        try</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">            var</span><span style="color:#D4D4D4;"> s = java.lang.Long.</span><span style="color:#DCDCAA;">valueOf</span><span style="color:#D4D4D4;">(st.</span><span style="color:#DCDCAA;">split</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;av&quot;</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">toRegex</span><span style="color:#D4D4D4;">()).</span><span style="color:#DCDCAA;">dropLastWhile</span><span style="color:#D4D4D4;"> { it.</span><span style="color:#DCDCAA;">isEmpty</span><span style="color:#D4D4D4;">() }</span></span>
<span class="line"><span style="color:#D4D4D4;">                .</span><span style="color:#DCDCAA;">toTypedArray</span><span style="color:#D4D4D4;">()[</span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">])</span></span>
<span class="line"><span style="color:#569CD6;">            val</span><span style="color:#D4D4D4;"> sb = </span><span style="color:#DCDCAA;">StringBuffer</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;BV1  4 1 7  &quot;</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#6A9955;">            //逆向思路，先将随机数还原</span></span>
<span class="line"><span style="color:#D4D4D4;">            s = (s xor xor) + add</span></span>
<span class="line"><span style="color:#6A9955;">            //58进制转回</span></span>
<span class="line"><span style="color:#C586C0;">            for</span><span style="color:#D4D4D4;"> (i </span><span style="color:#569CD6;">in</span><span style="color:#B5CEA8;"> 0</span><span style="color:#D4D4D4;">..</span><span style="color:#B5CEA8;">57</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#569CD6;">                val</span><span style="color:#D4D4D4;"> s1 = table.</span><span style="color:#DCDCAA;">substring</span><span style="color:#D4D4D4;">(i, i + </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">                mp2[i] = s1</span></span>
<span class="line"><span style="color:#D4D4D4;">            }</span></span>
<span class="line"><span style="color:#C586C0;">            for</span><span style="color:#D4D4D4;"> (i </span><span style="color:#569CD6;">in</span><span style="color:#B5CEA8;"> 0</span><span style="color:#D4D4D4;">..</span><span style="color:#B5CEA8;">5</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#569CD6;">                val</span><span style="color:#D4D4D4;"> r = mp2[(s / </span><span style="color:#DCDCAA;">power</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, i) % </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">).</span><span style="color:#DCDCAA;">toInt</span><span style="color:#D4D4D4;">()]</span></span>
<span class="line"><span style="color:#D4D4D4;">                sb.</span><span style="color:#DCDCAA;">replace</span><span style="color:#D4D4D4;">(ss[i], ss[i] + </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">, r!!)</span></span>
<span class="line"><span style="color:#D4D4D4;">            }</span></span>
<span class="line"><span style="color:#C586C0;">            return</span><span style="color:#D4D4D4;"> sb.</span><span style="color:#DCDCAA;">toString</span><span style="color:#D4D4D4;">()</span></span>
<span class="line"><span style="color:#D4D4D4;">        } </span><span style="color:#569CD6;">catch</span><span style="color:#D4D4D4;"> (e: </span><span style="color:#4EC9B0;">ArrayIndexOutOfBoundsException</span><span style="color:#D4D4D4;">) {</span></span>
<span class="line"><span style="color:#C586C0;">            return</span><span style="color:#CE9178;"> &quot;&quot;</span></span>
<span class="line"><span style="color:#D4D4D4;">        }</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="golang-1" tabindex="-1"><a class="header-anchor" href="#golang-1"><span>Golang</span></a></h4><div class="language-go line-numbers-mode" data-highlighter="shiki" data-ext="go" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-go"><span class="line"><span style="color:#569CD6;">package</span><span style="color:#4EC9B0;"> main</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C586C0;">import</span><span style="color:#CE9178;"> &quot;math&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#4FC1FF;"> TABLE</span><span style="color:#D4D4D4;"> = </span><span style="color:#CE9178;">&quot;fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF&quot;</span></span>
<span class="line"><span style="color:#569CD6;">var</span><span style="color:#9CDCFE;"> S</span><span style="color:#D4D4D4;"> = [</span><span style="color:#B5CEA8;">11</span><span style="color:#D4D4D4;">]</span><span style="color:#4EC9B0;">uint</span><span style="color:#D4D4D4;">{</span><span style="color:#B5CEA8;">11</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">}</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#4FC1FF;"> XOR</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">177451812</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#4FC1FF;"> ADD</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">8728348608</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">var</span><span style="color:#9CDCFE;"> TR</span><span style="color:#D4D4D4;"> = </span><span style="color:#569CD6;">map</span><span style="color:#D4D4D4;">[</span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;">]</span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">{}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">// 初始化 TR</span></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> init</span><span style="color:#D4D4D4;">() {</span></span>
<span class="line"><span style="color:#C586C0;">	for</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> := </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;"> &lt; </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">++ {</span></span>
<span class="line"><span style="color:#9CDCFE;">		TR</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">TABLE</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">:</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">+</span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">]] = </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">	}</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> BV2AV</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bv</span><span style="color:#4EC9B0;"> string</span><span style="color:#D4D4D4;">) </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#9CDCFE;">	r</span><span style="color:#D4D4D4;"> := </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#C586C0;">	for</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> := </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;"> &lt; </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">++ {</span></span>
<span class="line"><span style="color:#9CDCFE;">		r</span><span style="color:#D4D4D4;"> += </span><span style="color:#9CDCFE;">TR</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">bv</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">S</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]:</span><span style="color:#9CDCFE;">S</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]+</span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">]] * </span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">math</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">Pow</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, </span><span style="color:#4EC9B0;">float64</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">)))</span></span>
<span class="line"><span style="color:#D4D4D4;">	}</span></span>
<span class="line"><span style="color:#C586C0;">	return</span><span style="color:#D4D4D4;"> (</span><span style="color:#9CDCFE;">r</span><span style="color:#D4D4D4;"> - </span><span style="color:#9CDCFE;">ADD</span><span style="color:#D4D4D4;">) ^ </span><span style="color:#9CDCFE;">XOR</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> AV2BV</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">av</span><span style="color:#4EC9B0;"> int64</span><span style="color:#D4D4D4;">) </span><span style="color:#4EC9B0;">string</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#9CDCFE;">	x</span><span style="color:#D4D4D4;"> := (</span><span style="color:#9CDCFE;">av</span><span style="color:#D4D4D4;"> ^ </span><span style="color:#9CDCFE;">XOR</span><span style="color:#D4D4D4;">) + </span><span style="color:#9CDCFE;">ADD</span></span>
<span class="line"><span style="color:#9CDCFE;">	r</span><span style="color:#D4D4D4;"> := []</span><span style="color:#4EC9B0;">rune</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;BV1  4 1 7  &quot;</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#C586C0;">	for</span><span style="color:#9CDCFE;"> i</span><span style="color:#D4D4D4;"> := </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;"> &lt; </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">; </span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">++ {</span></span>
<span class="line"><span style="color:#9CDCFE;">		r</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">S</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]] = </span><span style="color:#4EC9B0;">rune</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">TABLE</span><span style="color:#D4D4D4;">[</span><span style="color:#9CDCFE;">x</span><span style="color:#D4D4D4;">/</span><span style="color:#4EC9B0;">int64</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">math</span><span style="color:#D4D4D4;">.</span><span style="color:#DCDCAA;">Pow</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, </span><span style="color:#4EC9B0;">float64</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">)))%</span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">])</span></span>
<span class="line"><span style="color:#D4D4D4;">	}</span></span>
<span class="line"><span style="color:#C586C0;">	return</span><span style="color:#4EC9B0;"> string</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">r</span><span style="color:#D4D4D4;">)</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">func</span><span style="color:#DCDCAA;"> main</span><span style="color:#D4D4D4;">() {</span></span>
<span class="line"><span style="color:#DCDCAA;">	println</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">AV2BV</span><span style="color:#D4D4D4;">(</span><span style="color:#B5CEA8;">170001</span><span style="color:#D4D4D4;">))</span></span>
<span class="line"><span style="color:#DCDCAA;">	println</span><span style="color:#D4D4D4;">(</span><span style="color:#DCDCAA;">BV2AV</span><span style="color:#D4D4D4;">(</span><span style="color:#CE9178;">&quot;BV17x411w7KC&quot;</span><span style="color:#D4D4D4;">))</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>输出为：</p><div class="language- line-numbers-mode" data-highlighter="shiki" data-ext="" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-"><span class="line"><span>BV17x411w7KC</span></span>
<span class="line"><span>170001</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="rust-1" tabindex="-1"><a class="header-anchor" href="#rust-1"><span>Rust</span></a></h4><p>crate: https://github.com/stackinspector/bvid</p><div class="language-rust line-numbers-mode" data-highlighter="shiki" data-ext="rust" style="background-color:#1E1E1E;color:#D4D4D4;"><pre class="shiki dark-plus vp-code"><code class="language-rust"><span class="line"><span style="color:#6A9955;">// Copyright (c) 2023 stackinspector. MIT license.</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#D4D4D4;"> XORN: </span><span style="color:#4EC9B0;">u64</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">177451812</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#D4D4D4;"> ADDN: </span><span style="color:#4EC9B0;">u64</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">100618342136696320</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#D4D4D4;"> TABLE: [</span><span style="color:#4EC9B0;">u8</span><span style="color:#D4D4D4;">; </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">] = *</span><span style="color:#CE9178;">b&quot;fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF&quot;</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#D4D4D4;"> MAP: [</span><span style="color:#4EC9B0;">usize</span><span style="color:#D4D4D4;">; </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">] = [</span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">2</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">5</span><span style="color:#D4D4D4;">];</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#D4D4D4;"> REV_TABLE: [</span><span style="color:#4EC9B0;">u8</span><span style="color:#D4D4D4;">; </span><span style="color:#B5CEA8;">74</span><span style="color:#D4D4D4;">] = [</span></span>
<span class="line"><span style="color:#B5CEA8;">    13</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">12</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">46</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">31</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">43</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">18</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">40</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">28</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">5</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">54</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">20</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">15</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">8</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    39</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">57</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">45</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">36</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">38</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">51</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">42</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">49</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">52</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">53</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">7</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">4</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">9</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">50</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">44</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">34</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">6</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    25</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">1</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">26</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">29</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">56</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">3</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">24</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">47</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">27</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">22</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">41</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">16</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    11</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">37</span><span style="color:#D4D4D4;">,  </span><span style="color:#B5CEA8;">2</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">35</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">21</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">17</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">33</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">30</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">48</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">23</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">55</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">32</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">14</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">19</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#D4D4D4;">];</span></span>
<span class="line"><span style="color:#569CD6;">const</span><span style="color:#D4D4D4;"> POW58: [</span><span style="color:#4EC9B0;">u64</span><span style="color:#D4D4D4;">; </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">] = [</span></span>
<span class="line"><span style="color:#B5CEA8;">    1</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">3364</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">195112</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">11316496</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">656356768</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">38068692544</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#B5CEA8;">    2207984167552</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">128063081718016</span><span style="color:#D4D4D4;">, </span><span style="color:#B5CEA8;">7427658739644928</span><span style="color:#D4D4D4;">,</span></span>
<span class="line"><span style="color:#D4D4D4;">];</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">fn</span><span style="color:#DCDCAA;"> av2bv</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">avid</span><span style="color:#D4D4D4;">: </span><span style="color:#4EC9B0;">u64</span><span style="color:#D4D4D4;">) -&gt; [</span><span style="color:#4EC9B0;">u8</span><span style="color:#D4D4D4;">; </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">] {</span></span>
<span class="line"><span style="color:#569CD6;">    let</span><span style="color:#9CDCFE;"> a</span><span style="color:#D4D4D4;"> = (</span><span style="color:#9CDCFE;">avid</span><span style="color:#D4D4D4;"> ^ XORN) + ADDN;</span></span>
<span class="line"><span style="color:#569CD6;">    let</span><span style="color:#569CD6;"> mut</span><span style="color:#9CDCFE;"> bvid</span><span style="color:#D4D4D4;"> = [</span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">; </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">];</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#9CDCFE;"> i</span><span style="color:#569CD6;"> in</span><span style="color:#B5CEA8;"> 0</span><span style="color:#D4D4D4;">..</span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#9CDCFE;">        bvid</span><span style="color:#D4D4D4;">[MAP[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]] = TABLE[(</span><span style="color:#9CDCFE;">a</span><span style="color:#D4D4D4;"> / POW58[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]) </span><span style="color:#569CD6;">as</span><span style="color:#4EC9B0;"> usize</span><span style="color:#D4D4D4;"> % </span><span style="color:#B5CEA8;">58</span><span style="color:#D4D4D4;">];</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#9CDCFE;">    bvid</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#569CD6;">fn</span><span style="color:#DCDCAA;"> bv2av</span><span style="color:#D4D4D4;">(</span><span style="color:#9CDCFE;">bvid</span><span style="color:#D4D4D4;">: [</span><span style="color:#4EC9B0;">u8</span><span style="color:#D4D4D4;">; </span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;">]) -&gt; </span><span style="color:#4EC9B0;">u64</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#569CD6;">    let</span><span style="color:#569CD6;"> mut</span><span style="color:#9CDCFE;"> a</span><span style="color:#D4D4D4;"> = </span><span style="color:#B5CEA8;">0</span><span style="color:#D4D4D4;">;</span></span>
<span class="line"><span style="color:#C586C0;">    for</span><span style="color:#9CDCFE;"> i</span><span style="color:#569CD6;"> in</span><span style="color:#B5CEA8;"> 0</span><span style="color:#D4D4D4;">..</span><span style="color:#B5CEA8;">10</span><span style="color:#D4D4D4;"> {</span></span>
<span class="line"><span style="color:#9CDCFE;">        a</span><span style="color:#D4D4D4;"> += REV_TABLE[</span><span style="color:#9CDCFE;">bvid</span><span style="color:#D4D4D4;">[MAP[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">]] </span><span style="color:#569CD6;">as</span><span style="color:#4EC9B0;"> usize</span><span style="color:#D4D4D4;"> - </span><span style="color:#B5CEA8;">49</span><span style="color:#D4D4D4;">] </span><span style="color:#569CD6;">as</span><span style="color:#4EC9B0;"> u64</span><span style="color:#D4D4D4;"> * POW58[</span><span style="color:#9CDCFE;">i</span><span style="color:#D4D4D4;">];</span></span>
<span class="line"><span style="color:#D4D4D4;">    }</span></span>
<span class="line"><span style="color:#D4D4D4;">    (</span><span style="color:#9CDCFE;">a</span><span style="color:#D4D4D4;"> - ADDN) ^ XORN</span></span>
<span class="line"><span style="color:#D4D4D4;">}</span></span>
<span class="line"></span>
<span class="line"><span style="color:#6A9955;">// assert_eq!(*b&quot;17x411w7KC&quot;, av2bv(170001));</span></span>
<span class="line"><span style="color:#6A9955;">// assert_eq!(170001, bv2av(*b&quot;17x411w7KC&quot;));</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></details>`,16))])}const E=r(i,[["render",C]]),A=JSON.parse('{"path":"/docs/misc/bvid_desc.html","title":"bvid说明","lang":"zh-CN","frontmatter":{},"git":{"updatedTime":1745082190000,"contributors":[{"name":"SocialSisterYi","username":"SocialSisterYi","email":"1440239038@qq.com","commits":4,"url":"https://github.com/SocialSisterYi"},{"name":"zine0","username":"zine0","email":"46991452+zine0@users.noreply.github.com","commits":1,"url":"https://github.com/zine0"},{"name":"stackinspector","username":"stackinspector","email":"stackinspector@126.com","commits":2,"url":"https://github.com/stackinspector"},{"name":"EvanHsieh0415","username":"EvanHsieh0415","email":"74277414+EvanHsieh0415@users.noreply.github.com","commits":1,"url":"https://github.com/EvanHsieh0415"},{"name":"Kataick","username":"Kataick","email":"24969684+Kataick@users.noreply.github.com","commits":2,"url":"https://github.com/Kataick"},{"name":"LaMerChiang","username":"LaMerChiang","email":"catlair@qq.com","commits":2,"url":"https://github.com/LaMerChiang"},{"name":"WindowsMEMZ","username":"WindowsMEMZ","email":"45706356+WindowsMEMZ@users.noreply.github.com","commits":1,"url":"https://github.com/WindowsMEMZ"},{"name":"F-park","username":"F-park","email":"52167622+F-park@users.noreply.github.com","commits":1,"url":"https://github.com/F-park"},{"name":"GalaxySnail","username":"GalaxySnail","email":"me@glxys.nl","commits":4,"url":"https://github.com/GalaxySnail"},{"name":"cctyl","username":"cctyl","email":"34262992+cctyl@users.noreply.github.com","commits":1,"url":"https://github.com/cctyl"},{"name":"YuHuanTin","username":"YuHuanTin","email":"51024916+YuHuanTin@users.noreply.github.com","commits":1,"url":"https://github.com/YuHuanTin"},{"name":"WShihan","username":"WShihan","email":"52617949+WShihan@users.noreply.github.com","commits":1,"url":"https://github.com/WShihan"},{"name":"wsh","username":"wsh","email":"3443327820@qq.com","commits":1,"url":"https://github.com/wsh"},{"name":"SessionHu","username":"SessionHu","email":"102411014+SessionHu@users.noreply.github.com","commits":2,"url":"https://github.com/SessionHu"}],"changelog":[{"hash":"ea76fb00e62ee9a486ee010e67d73a133ba9b7af","time":1745082190000,"email":"102411014+SessionHu@users.noreply.github.com","author":"SessionHu","message":"fix(misc/bvid_desc.md): cpp highlight &#x26; remove old links"},{"hash":"18c1efbc102ae6b44c8f5314c90e5e64f0d926cd","time":1721909032000,"email":"102411014+SessionHu@users.noreply.github.com","author":"Session小胡","message":"feat: bili_ticket 算法 Java 实现 及 信息补充 及 错误修正 (#1061)"},{"hash":"ce07d83125fa265810272867211bbc16f9a85ff2","time":1718806390000,"email":"52617949+WShihan@users.noreply.github.com","author":"wsh","message":"feat: bv&#x3C;-->av algo implemented in golang (#1027)","coAuthors":[{"name":"wsh","email":"3443327820@qq.com"}]},{"hash":"e7ab2d770b423a891ed7e663d94bfe1f0f59501d","time":1718245563000,"email":"51024916+YuHuanTin@users.noreply.github.com","author":"YuHuanTin","message":"wbi、av2bv、bv2av 的 c++ 实现 (#1035)"},{"hash":"11d42851ae07fd95f8af37a354c672f07f999ad2","time":1716219747000,"email":"34262992+cctyl@users.noreply.github.com","author":"cctyl","message":"feat: bv&#x3C;-->av 增加java实现 (#1021)"},{"hash":"7b22c145d25f3ad725fce78c525254ebe60cf673","time":1707387835000,"email":"me@glxys.nl","author":"GalaxySnail","message":"docs/misc/bvid_desc.md: 不需要将 bvid 转换为 list"},{"hash":"3387e547bbd1d9b60ecebaeb542d6bce0bbb314f","time":1707387424000,"email":"me@glxys.nl","author":"GalaxySnail","message":"docs/misc/bvid_desc.md: 使用整数除法代替浮点数除法"},{"hash":"6fd4109cc0fee441271d664d53449e7849333639","time":1707387324000,"email":"me@glxys.nl","author":"GalaxySnail","message":"docs/misc/bvid_desc.md: 删除未使用的 BV_LEN 变量"},{"hash":"a53d158ee6e1422e85bb1f3197e887242da6227d","time":1707387257000,"email":"me@glxys.nl","author":"GalaxySnail","message":"docs/misc/bvid_desc.md: 删除多余的行尾空格"},{"hash":"33bde6f6afcac2ff8c6f7069f08ce84065a6cff6","time":1707041879000,"email":"1440239038@qq.com","author":"SocialSisterYi","message":"Update av2bv Python Demo"},{"hash":"f16cfe9793d233c81a006c1b5ac907905cea38ff","time":1706768036000,"email":"24969684+Kataick@users.noreply.github.com","author":"Kataick","message":"规范bv转av(python)示例的类型 (#960)"},{"hash":"1045da3751a8a5916fb2b3428ad902c4d4e14115","time":1704755026000,"email":"52167622+F-park@users.noreply.github.com","author":"F-park","message":"fix typo in <code>bvid_desc.md</code> (#928)"},{"hash":"27308c22c83e14bb67ac39425574dfbe32aa0b89","time":1702173833000,"email":"45706356+WindowsMEMZ@users.noreply.github.com","author":"Mark Chan","message":"为avid-bvid转换和Wbi签名添加Swift实现 (#890)"},{"hash":"507f20e88df2a5a0ba8c2bb980a1523e29dcf8d2","time":1700364910000,"email":"catlair@qq.com","author":"LaMerChiang","message":"更新 bvid 算法 (#862)"},{"hash":"6430bffbd66dbd6051bd420cd066ec8976a85452","time":1700098532000,"email":"catlair@qq.com","author":"LaMerChiang","message":"更新 bvid 算法 (#857)"},{"hash":"03eaaf52dc1d8a5bf1aeb847d5b42b681334551c","time":1696392355000,"email":"24969684+Kataick@users.noreply.github.com","author":"Kataick","message":"fix av2bv (#834)"},{"hash":"08e41c70e751a91097a753f2d9f935687d31c034","time":1695680686000,"email":"74277414+EvanHsieh0415@users.noreply.github.com","author":"Mango Jelly Pudding","message":"Update bvid_desc.md (#824)"},{"hash":"05ac3d5e2a9e28be3bf129ae8c78ffdbebaa161c","time":1684805901000,"email":"1440239038@qq.com","author":"SocialSisterYi","message":"添加文档【Wbi 接口签名】，修改目录结构"},{"hash":"dc5c527a1fe46d1d787d77d49e907e1ef7b03e67","time":1684179507000,"email":"stackinspector@126.com","author":"stackinspector","message":"添加Rust版本bvid算法示例"},{"hash":"f8a8f8a245c18a157c246246090f1e948b25fbab","time":1684176978000,"email":"stackinspector@126.com","author":"stackinspector","message":"添加Rust版本bvid算法"},{"hash":"06e8343031c77b39b97206542b9556d44ea64014","time":1684088758000,"email":"46991452+zine0@users.noreply.github.com","author":"zine_yu","message":"fix(docs/other/bvid_desc.md) (#663)"},{"hash":"f6760f4be38d5b592d396b211e48c666286524de","time":1677124138000,"email":"1440239038@qq.com","author":"SocialSisterYi","message":"🔨remove header index"},{"hash":"7d89ece2ac46425810647c4ac92acf5f3721cb68","time":1676998806000,"email":"1440239038@qq.com","author":"SocialSisterYi","message":"🚀调整项目结构"}]},"filePathRelative":"docs/misc/bvid_desc.md"}');export{E as comp,A as data};
