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

📄 sduhexdump.c

📁 文件驱动加密,功能强大,可产生加密分区,支持AES,MD2,MD4,MD5MD2, MD4, MD5, RIPEMD-128, RIPEMD-160, SHA-1, SHA-224, SHA-256,
💻 C
字号:
#include <stdio.h>/* ========================================================================= *//*   Returns the *estimated* number of characters that a call to    SDUPrettyPrintHexwill require to prettyprint data.          */unsigned int SDUPrettyPrintHexBufReq(  const unsigned int bytes,  const int width){  int estLines;  int estBytesPerLine;  estLines = (bytes / width) + 1;  estBytesPerLine = (width * 4) + 8 + 6 + 3 + 4;  /*                             ^ 2 chars + space (hex rep) + 1 char (ASCII rep)                                  ^ offset                                      ^ 2 x column dividers                                              ^ newline  */  return (estLines * estBytesPerLine);}/* ========================================================================= *//*   Starting from offset "offset" (zero indexed) in "data", read "bytes" bytes   and populate "output" with a null terminated pretty printed representation   of data   Each line in "output" will relate to "width" bytes from "data"   data - Pointer to the data to be prettyprinted   offset - Offset from the start of data to begin prettyprinting from   bytes - Number of bytes from data to be prettyprinted   output - Pointer to a buffer to receive the prettprinted output            This must be at *least* SDUPrettyPrintHexBufReq bytes long   outputLength - Length of output buffer   Returns: 0 on success, nonzero on failure (e.g. output buffer too small)*/int SDUPrettyPrintHex(  const unsigned char *data,  const unsigned int offset,  const unsigned int bytes,  char* output,  unsigned int outputLength,  const int width){  int allOK;  unsigned int inputOffset;  unsigned int outputOffset;  int i;  allOK = 0;  if (SDUPrettyPrintHexBufReq(                              bytes,                              width                             ) > outputLength)    {    allOK = 1;    return allOK;    }  inputOffset = offset;  outputOffset = 0;  while (inputOffset < (offset+bytes))    {    /* Display offset */    outputOffset += sprintf(                            &(output[outputOffset]),                            "%.08X | ",                            inputOffset                           );    /* Hex representation */    for (i = 0; i < width; i++)      {      /* >= because we index from 0 */      if ((inputOffset+i) >= (offset+bytes))        {        outputOffset += sprintf(                                &(output[outputOffset]),                                "   "                               );        }      else        {        outputOffset += sprintf(                                &(output[outputOffset]),                                "%.02X ",                                data[(inputOffset+i)]                               );        }      }    outputOffset += sprintf(                            &(output[outputOffset]),                            "| "                           );    /* ASCII representation */    for (i = 0; i < width; i++)      {      /* >= because we index from 0 */      if ((inputOffset+i) >= (offset+bytes))        {        outputOffset += sprintf(                                &(output[outputOffset]),                                " "                               );        }      else        {        if (            (data[(inputOffset + i)] >= 32) &&            (data[(inputOffset + i)] < 127)           )          {          outputOffset += sprintf(                                  &(output[outputOffset]),                                  "%c",                                  data[(inputOffset + i)]                                 );          }        else          {          outputOffset += sprintf(                                  &(output[outputOffset]),                                  "."                                 );          }        }      }    outputOffset += sprintf(                            &(output[outputOffset]),                            "\n"                           );    inputOffset += width;    }  output[outputOffset] = 0;  return allOK;}/* ========================================================================= *//* ========================================================================= */

⌨️ 快捷键说明

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