ソースを参照

*** empty log message ***

David Rose 25 年 前
コミット
eefa9304cd
2 ファイル変更83 行追加83 行削除
  1. 64 64
      panda/src/downloader/crypto_utils.cxx
  2. 19 19
      panda/src/downloader/crypto_utils.h

+ 64 - 64
panda/src/downloader/crypto_utils.cxx

@@ -1,64 +1,64 @@
-// Filename: crypto_utils.cxx
-// Created by:  drose (07Nov00)
-//
-////////////////////////////////////////////////////////////////////
-
-// This file is compiled only if we have crypto++ installed.
-
-#include "crypto_utils.h"
-
-#include <md5.h>
-#include <files.h>
-
-#include <string>
-
-USING_NAMESPACE(CryptoPP);
-USING_NAMESPACE(std);
-
-uint 
-read32(istream& is) {
-  unsigned int ret = 0x0;
-  unsigned char b1, b2, b3, b4;
-  is >> b1;
-  is >> b2;
-  is >> b3;
-  is >> b4;
-  ret = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
-  return ret;
-}
-
-void 
-md5_a_file(const Filename &name, HashVal &ret) {
-  ostringstream os;
-  MD5 md5;
-
-  string fs = name.get_fullpath();
-  FileSource f(fs.c_str(), true, new HashFilter(md5, new FileSink(os)));
-
-  istringstream is(os.str());
-
-  ret[0] = read32(is);
-  ret[1] = read32(is);
-  ret[2] = read32(is);
-  ret[3] = read32(is);
-}
-
-void 
-md5_a_buffer(unsigned char* buf, unsigned long len, HashVal& ret) {
-  MD5 md5;
-
-  HashFilter hash(md5);
-  hash.Put((byte*)buf, len);
-  hash.Close();
-
-  unsigned char* outb;
-  unsigned long outl = hash.MaxRetrieveable();
-  outb = new uchar[outl];
-  hash.Get((byte*)outb, outl);
-  ret[0] = (outb[0] << 24) | (outb[1] << 16) | (outb[2] << 8) | outb[3];
-  ret[1] = (outb[4] << 24) | (outb[5] << 16) | (outb[6] << 8) | outb[7];
-  ret[2] = (outb[8] << 24) | (outb[9] << 16) | (outb[10] << 8) | outb[11];
-  ret[3] = (outb[12] << 24) | (outb[13] << 16) | (outb[14] << 8) | outb[15];
-  delete outb;
-}
-
+// Filename: crypto_utils.cxx
+// Created by:  drose (07Nov00)
+//
+////////////////////////////////////////////////////////////////////
+
+// This file is compiled only if we have crypto++ installed.
+
+#include "crypto_utils.h"
+
+#include <md5.h>
+#include <files.h>
+
+#include <string>
+
+USING_NAMESPACE(CryptoPP);
+USING_NAMESPACE(std);
+
+uint 
+read32(istream& is) {
+  unsigned int ret = 0x0;
+  unsigned char b1, b2, b3, b4;
+  is >> b1;
+  is >> b2;
+  is >> b3;
+  is >> b4;
+  ret = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
+  return ret;
+}
+
+void 
+md5_a_file(const Filename &name, HashVal &ret) {
+  ostringstream os;
+  MD5 md5;
+
+  string fs = name.get_fullpath();
+  FileSource f(fs.c_str(), true, new HashFilter(md5, new FileSink(os)));
+
+  istringstream is(os.str());
+
+  ret[0] = read32(is);
+  ret[1] = read32(is);
+  ret[2] = read32(is);
+  ret[3] = read32(is);
+}
+
+void 
+md5_a_buffer(unsigned char* buf, unsigned long len, HashVal& ret) {
+  MD5 md5;
+
+  HashFilter hash(md5);
+  hash.Put((byte*)buf, len);
+  hash.Close();
+
+  unsigned char* outb;
+  unsigned long outl = hash.MaxRetrieveable();
+  outb = new uchar[outl];
+  hash.Get((byte*)outb, outl);
+  ret[0] = (outb[0] << 24) | (outb[1] << 16) | (outb[2] << 8) | outb[3];
+  ret[1] = (outb[4] << 24) | (outb[5] << 16) | (outb[6] << 8) | outb[7];
+  ret[2] = (outb[8] << 24) | (outb[9] << 16) | (outb[10] << 8) | outb[11];
+  ret[3] = (outb[12] << 24) | (outb[13] << 16) | (outb[14] << 8) | outb[15];
+  delete outb;
+}
+

+ 19 - 19
panda/src/downloader/crypto_utils.h

@@ -1,19 +1,19 @@
-// Filename: crypto_utils.h
-// Created by:  drose (07Nov00)
-//
-////////////////////////////////////////////////////////////////////
-
-#ifndef CRYPTO_UTILS_H
-#define CRYPTO_UTILS_H
-
-#include <pandabase.h>
-#include <filename.h>
-#include <typedef.h>
-
-typedef uint HashVal[4];
-
-EXPCL_PANDAEXPRESS void md5_a_file(const Filename &fname, HashVal &ret);
-EXPCL_PANDAEXPRESS void md5_a_buffer(uchar *buf, ulong len, HashVal &ret);
-
-#endif
-
+// Filename: crypto_utils.h
+// Created by:  drose (07Nov00)
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef CRYPTO_UTILS_H
+#define CRYPTO_UTILS_H
+
+#include <pandabase.h>
+#include <filename.h>
+#include <typedef.h>
+
+typedef uint HashVal[4];
+
+EXPCL_PANDAEXPRESS void md5_a_file(const Filename &fname, HashVal &ret);
+EXPCL_PANDAEXPRESS void md5_a_buffer(uchar *buf, ulong len, HashVal &ret);
+
+#endif
+