⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conversions.java

📁 一个木马程序源码
💻 JAVA
字号:
/* *   File:  Conversions.java * *   Misc. data conversion routines. * *   version 1.02 v1a *   Copyright 1998, 1999 by Hush Communications Corporation, BWI */package hushcode;import java.math.BigInteger;final class Conversions{     static String bytesToHexString(byte[] b)   {      String outputString = "";      /*  Create a byte array with an extra byte with MSB 0        *  so BigInteger will return a positive number         */      byte[] bb = new byte[b.length+1];      bb[0] = 127;      System.arraycopy(b,0,bb,1,b.length);            /*  Create a BigInteger from the byte array, convert to a string       *  and chop off the first two characters, which represent        *  the previously added byte       */      outputString = new BigInteger(bb).toString(16).substring(2);      return outputString;   }  /**   *  This method accepts a hex string and returns a byte array.   *  The string must represent an integer number of bytes.   */   static byte[] hexStringToBytes(String hex)   {      byte[] bigIntBytes = new BigInteger(hex,16).toByteArray();      if (bigIntBytes.length > hex.length()/2)      {         byte[] outbytes = new byte[hex.length()/2];         System.arraycopy(bigIntBytes, bigIntBytes.length-outbytes.length,            outbytes, 0, outbytes.length);         return outbytes;      }      else if (bigIntBytes.length < hex.length()/2)      {         byte[] outbytes = new byte[hex.length()/2];         System.arraycopy(bigIntBytes, 0,            outbytes, outbytes.length - bigIntBytes.length, bigIntBytes.length);         return outbytes;      }      else return bigIntBytes;   }   /*  this function accepts 8 bytes and returns a long integer    */   static long bytesToLong(byte[] bytes)   {      boolean negative = false;      long returnLong = 0;      for (int n=0; n<8; n++)      {          returnLong = returnLong << 8;              long aByte = bytes[n];         if (aByte<0) aByte = aByte + 256;         returnLong = returnLong | aByte;      }      return returnLong;    }   static byte[] longToBytes(long l)   {      long ll = l;      long mask = 255;      byte[] returnBytes = new byte[8];      long temp = 0;      for (int n=7; n>=0; n--)      {         temp = ll & mask;         if (temp > 127) temp = temp - 256;         returnBytes[n] = (byte)ll;         ll = ll >>> 8;      }      return returnBytes;   }   /*  this function accepts 8 bytes and returns a long integer    */   static int bytesToInt(byte[] bytes)   {      boolean negative = false;      int returnInt = 0;      for (int n=0; n<4; n++)      {          returnInt = returnInt << 8;              int aByte = bytes[n];         if (aByte<0) aByte = aByte + 256;         returnInt = returnInt | aByte;      }      return returnInt;    }   static byte[] intToBytes(int i)   {      int ii = i;      int mask = 255;      byte[] returnBytes = new byte[4];      int temp = 0;      for (int n=3; n>=0; n--)      {         temp = ii & mask;         if (temp > 127) temp = temp - 256;         returnBytes[n] = (byte)ii;         ii = ii >>> 8;      }      return returnBytes;   }}  //  end Conversions

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -