package com.newvideo.util.video; import java.util.Random; public class PPTVKey { public static int a(byte abyte0[], int i) { int j = 0; int k = 0; for (; j < i; j++) k ^= abyte0[j] << 8 * (j % 4); return k; } public static int a(byte abyte0[], int i, byte abyte1[], int j) { if (j < 1 + i * 2) return 0; for (int k = 0; k < i; k++) { abyte1[k * 2] = (byte) (0xf & abyte0[k]); abyte1[1 + k * 2] = (byte) (0xf & abyte0[k] >> 4); } int l = 0; while (l < i * 2) { byte byte0 = abyte1[l]; byte byte1; if (abyte1[l] > 9) byte1 = 87; else byte1 = 48; abyte1[l] = (byte) (byte0 + byte1); l++; } abyte1[i * 2] = 0; return 1; } public static String getKey(long l) { byte abyte0[] = new byte[16]; byte abyte1[] = new byte[16]; byte abyte2[] = new byte[33]; int i = 0; while (i < 16) { byte byte0; if (i < "qqqqqww".length()) byte0 = (byte) "qqqqqww".charAt(i); else byte0 = 0; abyte1[i] = byte0; i++; } a((int) (l / 1000L - 100L), abyte0, 16); Random random = new Random(); for (int j = 0; j < 16; j++) if (abyte0[j] == 0) abyte0[j] = (byte) random.nextInt(256); b(abyte0, 16, abyte1, 16); a(abyte0, 16, abyte2, 33); return new String(abyte2, 0, 32); } public static void a(int i, byte abyte0[], int j) { int k = 0; while (k < j && k < 8) { abyte0[k] = (byte) (0xf & i >> 28 - 4 * (k % 8)); byte byte0 = abyte0[k]; byte byte1; if (abyte0[k] > 9) byte1 = 87; else byte1 = 48; abyte0[k] = (byte) (byte0 + byte1); k++; } } public static long b(long l) { return 0xffffffffL & l; } public static void b(byte abyte0[], int i, byte abyte1[], int j) { long l = a(abyte1, j); long l1 = l << 8 | l >> 24; long l2 = l << 16 | l >> 16; long l3 = l << 24 | l >> 8; for (int k = 0; k + 16 <= i; k += 16) { long l4 = 0L; long l5 = 0L; long l6 = 0L; for (int i1 = 0; i1 < 4; i1++) { l4 |= (long) (0xff & abyte0[k + i1]) << i1 * 8; l5 |= (long) (0xff & abyte0[4 + (k + i1)]) << i1 * 8; } for (int j1 = 0; j1 < 32; j1++) { l6 = b(l6 - 0x61c88647L); l4 = b(l4 + (b(b(l + b(l5 << 4)) ^ b(l5 + l6)) ^ b(l1 + b(l5 >> 5)))); l5 = b(l5 + (b(b(l2 + b(l4 << 4)) ^ b(l4 + l6)) ^ b(l3 + b(l4 >> 5)))); } for (int k1 = 0; k1 < 4; k1++) { abyte0[k + k1] = (byte) (int) (255L & l4 >> k1 * 8); abyte0[4 + (k + k1)] = (byte) (int) (255L & l5 >> k1 * 8); } } } }