A3EZatGHlB4J5ro.png

Neko

GF  2021-04-19 15:31
(自购贴均为原档)

JavaScript兽音译者 嗷呜啊~

昨天把app反编译了,不能浪费啊,改个js版的

复制代码
  1. const beastDictArr = ['嗷', '呜', '啊', '~']
  2. function toBeast(rawStr) {
  3.     let charArr = rawStr.split("")
  4.     let unicodeHexStr = ""
  5.     for (let i = 0; i < charArr.length; i++) {
  6.         let charHexStr = charArr[i].charCodeAt(0).toString(16)
  7.         while (charHexStr.length < 4) {
  8.             charHexStr = "0" + charHexStr
  9.         }
  10.         unicodeHexStr += charHexStr
  11.     }
  12.     let k = 0
  13.     let unicodeHexStrArr = unicodeHexStr.split("")
  14.     let beastStr = ""
  15.     for (let i = 0; i < unicodeHexStrArr.length; i++) {
  16.         let unicodeHexCharValue = parseInt("0x" + unicodeHexStrArr[i])
  17.         k = unicodeHexCharValue + (i % 0x10)
  18.         if (k >= 0x10) {
  19.             k = k - 0x10;
  20.         }
  21.         beastStr += beastDictArr[parseInt(k / 4)] + beastDictArr[(k % 4)]
  22.     }
  23.     return "~呜嗷" + beastStr + "啊"
  24. }
  25. function fromBeast(decoratedBeastStr) {
  26.     let beastStr = decoratedBeastStr.substring(3, decoratedBeastStr.length - 1);
  27.     let unicodeHexStr = ""
  28.     let beastStrArr = beastStr.split("")
  29.     for (let i = 0; i <= (beastStr.length - 2); i += 2) {
  30.         let beastCharStr = ""
  31.         let pos1 = 0
  32.         beastCharStr = beastStrArr[i];
  33.         for (; pos1 <= 3; pos1++) {
  34.             if (beastCharStr == beastDictArr[pos1]) {
  35.                 break
  36.             }
  37.         }
  38.         let pos2 = 0
  39.         beastCharStr = beastStrArr[i + 1]
  40.         for (; pos2 <= 3; pos2++) {
  41.             if (beastCharStr == beastDictArr[pos2]) {
  42.                 break;
  43.             }
  44.         }
  45.         let k = (pos1 * 4) + pos2;
  46.         let unicodeHexCharValue = k - (parseInt(i / 2) % 0x10);
  47.         if (unicodeHexCharValue < 0) {
  48.             unicodeHexCharValue += 0x10;
  49.         }
  50.         unicodeHexStr += unicodeHexCharValue.toString(16)
  51.     }
  52.     let rawStr = ""
  53.     let start = 0
  54.     let end = 4
  55.     while (end <= unicodeHexStr.length) {
  56.         let charHexStr = unicodeHexStr.substring(start, end);
  57.         let charStr = String.fromCharCode(parseInt("0x" + charHexStr))
  58.         rawStr += charStr
  59.         start += 4
  60.         end += 4
  61.     }
  62.     return rawStr
  63. }


>>toBeast("你好")
"~呜嗷呜嗷嗷嗷啊嗷嗷~啊呜~啊~呜呜嗷啊"
>>fromBeast("~呜嗷呜嗷嗷嗷啊嗷嗷~啊呜~啊~呜呜嗷啊")
"你好"

359668.png

队长

"~呜嗷呜呜呜呜~啊啊~啊呜啊呜嗷啊~~~呜~呜呜啊嗷~嗷呜嗷呜啊啊呜~呜呜呜呜~啊啊~啊啊~嗷呜啊嗷嗷~啊啊啊啊啊啊啊嗷啊~呜~~~嗷呜呜呜啊嗷呜啊啊啊"

none.gif

dokidokidoki

"~呜嗷嗷嗷嗷呜啊呜呜~呜嗷呜呜~嗷~嗷啊嗷啊呜嗷呜~啊~嗷~呜呜呜嗷~啊"

none.gif

dokidokidoki

大概懂了,字符转Unicode编码,对4取模,取余,映射到四个字符上

953560.gif

Tifa

B4F  2021-04-19 16:24
(缘木求鱼 终不可得)
~呜嗷呜呜啊啊啊呜嗷嗷啊啊嗷啊啊呜嗷啊啊