Base64.smali 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. .class final Lokio/Base64;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # static fields
  5. .field private static final MAP:[B
  6. .field private static final URL_MAP:[B
  7. # direct methods
  8. .method static constructor <clinit>()V
  9. .locals 2
  10. const/16 v0, 0x40
  11. new-array v1, v0, [B
  12. fill-array-data v1, :array_0
  13. sput-object v1, Lokio/Base64;->MAP:[B
  14. new-array v0, v0, [B
  15. fill-array-data v0, :array_1
  16. sput-object v0, Lokio/Base64;->URL_MAP:[B
  17. return-void
  18. nop
  19. :array_0
  20. .array-data 1
  21. 0x41t
  22. 0x42t
  23. 0x43t
  24. 0x44t
  25. 0x45t
  26. 0x46t
  27. 0x47t
  28. 0x48t
  29. 0x49t
  30. 0x4at
  31. 0x4bt
  32. 0x4ct
  33. 0x4dt
  34. 0x4et
  35. 0x4ft
  36. 0x50t
  37. 0x51t
  38. 0x52t
  39. 0x53t
  40. 0x54t
  41. 0x55t
  42. 0x56t
  43. 0x57t
  44. 0x58t
  45. 0x59t
  46. 0x5at
  47. 0x61t
  48. 0x62t
  49. 0x63t
  50. 0x64t
  51. 0x65t
  52. 0x66t
  53. 0x67t
  54. 0x68t
  55. 0x69t
  56. 0x6at
  57. 0x6bt
  58. 0x6ct
  59. 0x6dt
  60. 0x6et
  61. 0x6ft
  62. 0x70t
  63. 0x71t
  64. 0x72t
  65. 0x73t
  66. 0x74t
  67. 0x75t
  68. 0x76t
  69. 0x77t
  70. 0x78t
  71. 0x79t
  72. 0x7at
  73. 0x30t
  74. 0x31t
  75. 0x32t
  76. 0x33t
  77. 0x34t
  78. 0x35t
  79. 0x36t
  80. 0x37t
  81. 0x38t
  82. 0x39t
  83. 0x2bt
  84. 0x2ft
  85. .end array-data
  86. :array_1
  87. .array-data 1
  88. 0x41t
  89. 0x42t
  90. 0x43t
  91. 0x44t
  92. 0x45t
  93. 0x46t
  94. 0x47t
  95. 0x48t
  96. 0x49t
  97. 0x4at
  98. 0x4bt
  99. 0x4ct
  100. 0x4dt
  101. 0x4et
  102. 0x4ft
  103. 0x50t
  104. 0x51t
  105. 0x52t
  106. 0x53t
  107. 0x54t
  108. 0x55t
  109. 0x56t
  110. 0x57t
  111. 0x58t
  112. 0x59t
  113. 0x5at
  114. 0x61t
  115. 0x62t
  116. 0x63t
  117. 0x64t
  118. 0x65t
  119. 0x66t
  120. 0x67t
  121. 0x68t
  122. 0x69t
  123. 0x6at
  124. 0x6bt
  125. 0x6ct
  126. 0x6dt
  127. 0x6et
  128. 0x6ft
  129. 0x70t
  130. 0x71t
  131. 0x72t
  132. 0x73t
  133. 0x74t
  134. 0x75t
  135. 0x76t
  136. 0x77t
  137. 0x78t
  138. 0x79t
  139. 0x7at
  140. 0x30t
  141. 0x31t
  142. 0x32t
  143. 0x33t
  144. 0x34t
  145. 0x35t
  146. 0x36t
  147. 0x37t
  148. 0x38t
  149. 0x39t
  150. 0x2dt
  151. 0x5ft
  152. .end array-data
  153. .end method
  154. .method private constructor <init>()V
  155. .locals 0
  156. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  157. return-void
  158. .end method
  159. .method public static decode(Ljava/lang/String;)[B
  160. .locals 14
  161. invoke-virtual {p0}, Ljava/lang/String;->length()I
  162. move-result v0
  163. :goto_0
  164. const/16 v1, 0x9
  165. const/16 v2, 0x20
  166. const/16 v3, 0xd
  167. const/16 v4, 0xa
  168. if-lez v0, :cond_1
  169. add-int/lit8 v5, v0, -0x1
  170. invoke-virtual {p0, v5}, Ljava/lang/String;->charAt(I)C
  171. move-result v5
  172. const/16 v6, 0x3d
  173. if-eq v5, v6, :cond_0
  174. if-eq v5, v4, :cond_0
  175. if-eq v5, v3, :cond_0
  176. if-eq v5, v2, :cond_0
  177. if-eq v5, v1, :cond_0
  178. goto :goto_1
  179. :cond_0
  180. add-int/lit8 v0, v0, -0x1
  181. goto :goto_0
  182. :cond_1
  183. :goto_1
  184. int-to-long v5, v0
  185. const-wide/16 v7, 0x6
  186. mul-long v5, v5, v7
  187. const-wide/16 v7, 0x8
  188. div-long/2addr v5, v7
  189. long-to-int v6, v5
  190. new-array v5, v6, [B
  191. const/4 v6, 0x0
  192. const/4 v7, 0x0
  193. const/4 v8, 0x0
  194. const/4 v9, 0x0
  195. const/4 v10, 0x0
  196. :goto_2
  197. const/4 v11, 0x0
  198. if-ge v7, v0, :cond_b
  199. invoke-virtual {p0, v7}, Ljava/lang/String;->charAt(I)C
  200. move-result v12
  201. const/16 v13, 0x41
  202. if-lt v12, v13, :cond_2
  203. const/16 v13, 0x5a
  204. if-gt v12, v13, :cond_2
  205. add-int/lit8 v12, v12, -0x41
  206. goto :goto_5
  207. :cond_2
  208. const/16 v13, 0x61
  209. if-lt v12, v13, :cond_3
  210. const/16 v13, 0x7a
  211. if-gt v12, v13, :cond_3
  212. add-int/lit8 v12, v12, -0x47
  213. goto :goto_5
  214. :cond_3
  215. const/16 v13, 0x30
  216. if-lt v12, v13, :cond_4
  217. const/16 v13, 0x39
  218. if-gt v12, v13, :cond_4
  219. add-int/lit8 v12, v12, 0x4
  220. goto :goto_5
  221. :cond_4
  222. const/16 v13, 0x2b
  223. if-eq v12, v13, :cond_9
  224. const/16 v13, 0x2d
  225. if-ne v12, v13, :cond_5
  226. goto :goto_4
  227. :cond_5
  228. const/16 v13, 0x2f
  229. if-eq v12, v13, :cond_8
  230. const/16 v13, 0x5f
  231. if-ne v12, v13, :cond_6
  232. goto :goto_3
  233. :cond_6
  234. if-eq v12, v4, :cond_a
  235. if-eq v12, v3, :cond_a
  236. if-eq v12, v2, :cond_a
  237. if-ne v12, v1, :cond_7
  238. goto :goto_6
  239. :cond_7
  240. return-object v11
  241. :cond_8
  242. :goto_3
  243. const/16 v12, 0x3f
  244. goto :goto_5
  245. :cond_9
  246. :goto_4
  247. const/16 v12, 0x3e
  248. :goto_5
  249. shl-int/lit8 v9, v9, 0x6
  250. int-to-byte v11, v12
  251. or-int/2addr v9, v11
  252. add-int/lit8 v8, v8, 0x1
  253. rem-int/lit8 v11, v8, 0x4
  254. if-nez v11, :cond_a
  255. add-int/lit8 v11, v10, 0x1
  256. shr-int/lit8 v12, v9, 0x10
  257. int-to-byte v12, v12
  258. aput-byte v12, v5, v10
  259. add-int/lit8 v10, v11, 0x1
  260. shr-int/lit8 v12, v9, 0x8
  261. int-to-byte v12, v12
  262. aput-byte v12, v5, v11
  263. add-int/lit8 v11, v10, 0x1
  264. int-to-byte v12, v9
  265. aput-byte v12, v5, v10
  266. move v10, v11
  267. :cond_a
  268. :goto_6
  269. add-int/lit8 v7, v7, 0x1
  270. goto :goto_2
  271. :cond_b
  272. rem-int/lit8 v8, v8, 0x4
  273. const/4 p0, 0x1
  274. if-ne v8, p0, :cond_c
  275. return-object v11
  276. :cond_c
  277. const/4 p0, 0x2
  278. if-ne v8, p0, :cond_d
  279. shl-int/lit8 p0, v9, 0xc
  280. add-int/lit8 v0, v10, 0x1
  281. shr-int/lit8 p0, p0, 0x10
  282. int-to-byte p0, p0
  283. aput-byte p0, v5, v10
  284. move v10, v0
  285. goto :goto_7
  286. :cond_d
  287. const/4 p0, 0x3
  288. if-ne v8, p0, :cond_e
  289. shl-int/lit8 p0, v9, 0x6
  290. add-int/lit8 v0, v10, 0x1
  291. shr-int/lit8 v1, p0, 0x10
  292. int-to-byte v1, v1
  293. aput-byte v1, v5, v10
  294. add-int/lit8 v10, v0, 0x1
  295. shr-int/lit8 p0, p0, 0x8
  296. int-to-byte p0, p0
  297. aput-byte p0, v5, v0
  298. :cond_e
  299. :goto_7
  300. array-length p0, v5
  301. if-ne v10, p0, :cond_f
  302. return-object v5
  303. :cond_f
  304. new-array p0, v10, [B
  305. invoke-static {v5, v6, p0, v6, v10}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
  306. return-object p0
  307. .end method
  308. .method public static encode([B)Ljava/lang/String;
  309. .locals 1
  310. sget-object v0, Lokio/Base64;->MAP:[B
  311. invoke-static {p0, v0}, Lokio/Base64;->encode([B[B)Ljava/lang/String;
  312. move-result-object p0
  313. return-object p0
  314. .end method
  315. .method private static encode([B[B)Ljava/lang/String;
  316. .locals 9
  317. array-length v0, p0
  318. const/4 v1, 0x2
  319. add-int/2addr v0, v1
  320. div-int/lit8 v0, v0, 0x3
  321. mul-int/lit8 v0, v0, 0x4
  322. new-array v0, v0, [B
  323. array-length v2, p0
  324. array-length v3, p0
  325. rem-int/lit8 v3, v3, 0x3
  326. sub-int/2addr v2, v3
  327. const/4 v3, 0x0
  328. const/4 v4, 0x0
  329. :goto_0
  330. if-ge v3, v2, :cond_0
  331. add-int/lit8 v5, v4, 0x1
  332. aget-byte v6, p0, v3
  333. and-int/lit16 v6, v6, 0xff
  334. shr-int/2addr v6, v1
  335. aget-byte v6, p1, v6
  336. aput-byte v6, v0, v4
  337. add-int/lit8 v4, v5, 0x1
  338. aget-byte v6, p0, v3
  339. and-int/lit8 v6, v6, 0x3
  340. shl-int/lit8 v6, v6, 0x4
  341. add-int/lit8 v7, v3, 0x1
  342. aget-byte v8, p0, v7
  343. and-int/lit16 v8, v8, 0xff
  344. shr-int/lit8 v8, v8, 0x4
  345. or-int/2addr v6, v8
  346. aget-byte v6, p1, v6
  347. aput-byte v6, v0, v5
  348. add-int/lit8 v5, v4, 0x1
  349. aget-byte v6, p0, v7
  350. and-int/lit8 v6, v6, 0xf
  351. shl-int/2addr v6, v1
  352. add-int/lit8 v7, v3, 0x2
  353. aget-byte v8, p0, v7
  354. and-int/lit16 v8, v8, 0xff
  355. shr-int/lit8 v8, v8, 0x6
  356. or-int/2addr v6, v8
  357. aget-byte v6, p1, v6
  358. aput-byte v6, v0, v4
  359. add-int/lit8 v4, v5, 0x1
  360. aget-byte v6, p0, v7
  361. and-int/lit8 v6, v6, 0x3f
  362. aget-byte v6, p1, v6
  363. aput-byte v6, v0, v5
  364. add-int/lit8 v3, v3, 0x3
  365. goto :goto_0
  366. :cond_0
  367. array-length v3, p0
  368. rem-int/lit8 v3, v3, 0x3
  369. const/16 v5, 0x3d
  370. const/4 v6, 0x1
  371. if-eq v3, v6, :cond_2
  372. if-eq v3, v1, :cond_1
  373. goto :goto_1
  374. :cond_1
  375. add-int/lit8 v3, v4, 0x1
  376. aget-byte v7, p0, v2
  377. and-int/lit16 v7, v7, 0xff
  378. shr-int/2addr v7, v1
  379. aget-byte v7, p1, v7
  380. aput-byte v7, v0, v4
  381. add-int/lit8 v4, v3, 0x1
  382. aget-byte v7, p0, v2
  383. and-int/lit8 v7, v7, 0x3
  384. shl-int/lit8 v7, v7, 0x4
  385. add-int/2addr v2, v6
  386. aget-byte v6, p0, v2
  387. and-int/lit16 v6, v6, 0xff
  388. shr-int/lit8 v6, v6, 0x4
  389. or-int/2addr v6, v7
  390. aget-byte v6, p1, v6
  391. aput-byte v6, v0, v3
  392. add-int/lit8 v3, v4, 0x1
  393. aget-byte p0, p0, v2
  394. and-int/lit8 p0, p0, 0xf
  395. shl-int/2addr p0, v1
  396. aget-byte p0, p1, p0
  397. aput-byte p0, v0, v4
  398. aput-byte v5, v0, v3
  399. goto :goto_1
  400. :cond_2
  401. add-int/lit8 v3, v4, 0x1
  402. aget-byte v6, p0, v2
  403. and-int/lit16 v6, v6, 0xff
  404. shr-int/lit8 v1, v6, 0x2
  405. aget-byte v1, p1, v1
  406. aput-byte v1, v0, v4
  407. add-int/lit8 v1, v3, 0x1
  408. aget-byte p0, p0, v2
  409. and-int/lit8 p0, p0, 0x3
  410. shl-int/lit8 p0, p0, 0x4
  411. aget-byte p0, p1, p0
  412. aput-byte p0, v0, v3
  413. add-int/lit8 p0, v1, 0x1
  414. aput-byte v5, v0, v1
  415. aput-byte v5, v0, p0
  416. :goto_1
  417. :try_start_0
  418. new-instance p0, Ljava/lang/String;
  419. const-string p1, "US-ASCII"
  420. invoke-direct {p0, v0, p1}, Ljava/lang/String;-><init>([BLjava/lang/String;)V
  421. :try_end_0
  422. .catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_0} :catch_0
  423. return-object p0
  424. :catch_0
  425. move-exception p0
  426. new-instance p1, Ljava/lang/AssertionError;
  427. invoke-direct {p1, p0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  428. goto :goto_3
  429. :goto_2
  430. throw p1
  431. :goto_3
  432. goto :goto_2
  433. .end method
  434. .method public static encodeUrl([B)Ljava/lang/String;
  435. .locals 1
  436. sget-object v0, Lokio/Base64;->URL_MAP:[B
  437. invoke-static {p0, v0}, Lokio/Base64;->encode([B[B)Ljava/lang/String;
  438. move-result-object p0
  439. return-object p0
  440. .end method