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

📄 dorandom.c

📁 非常经典的加密算法
💻 C
字号:
/* Copyright 2000 Enhanced Software Technologies Inc.   All Rights Reserved.   Released under a BSD-style license. See file LICENSE for details.   dorandom.c -- read /dev/urandom.RCS CHANGE LOG:$Log: dorandom.c,v $Revision 1.4  2000/04/24 19:46:57  ericMore autoconf tweaks. Changed to using Counterpane's TwoFish rather thanDr. Gladman's TwoFish in an attempt to fix the big endian/little endianproblems once and for all.Revision 1.2  2000/04/05 22:09:19  ericDaily checkin...Revision 1.1  2000/03/28 23:54:28  ericInitial checkin -- aescrypt/aesget$Date: 2000/04/24 19:46:57 $*/#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdlib.h>#include <unistd.h>#include "dorandom.h"static int infile;int urand_seed(char *filename) {  char *name;  if (filename) {    name=filename;  } else {    name=URAND_NAME;  }  infile=open(name,O_RDONLY);  if (infile <= 0) {    return 1; /* could not open! */  }  return 0; /* all okay! */}char *urand_get(int numbytes) {  char *retval;  int result;  retval=(char *)malloc(numbytes);  if (!retval) {    fprintf(stderr,"dorandom:urand_get:error:out of memory.");    exit(1); /* sorry :-(. */  }      result=read(infile,retval,numbytes);  if (result < numbytes) {    free(retval);    return NULL; /* couldn't do it :-( */  }  return retval;}

⌨️ 快捷键说明

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