Changes between Version 40 and Version 41 of HashSourceCodes


Ignore:
Timestamp:
Feb 9, 2013, 3:18:22 PM (12 years ago)
Author:
os
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HashSourceCodes

    v40 v41  
    248248or without using GetHash.dll:
    249249{{{
     250#!c#
    250251using System;
    251252using System.Text;
     
    315316== VB.Net ==
    316317{{{
     318#!vba
    317319Imports System
    318320Imports System.Text
     
    417419
    418420{{{
     421#!delphi
    419422function CalcGabestHash(const fname: string): string;
    420423var
     
    460463== Lua ==
    461464{{{
     465#!lua
    462466-- will produce a correct hash regardless of architecture (big vs little endian)
    463467local function movieHash(fileName)
     
    518522
    519523{{{
     524#!realbasic
    520525    dim b as BinaryStream
    521526    dim mb as MemoryBlock
     
    816821== Haskell ==
    817822{{{
     823#!haskell
    818824import IO(bracket)
    819825import System.Environment(getArgs)
     
    848854[http://www.autoitscript.com/forum/topic/107155-opensubtitles-org-hashing-func/page__p__755889__hl__opensubtitles__fromsearch__1#entry755889 Forum entry]
    849855{{{
     856#!autoit
    850857#cs
    851858        Hash code is based on Media Player Classic. It calculates: size + 64bit
     
    887894== !FoxPro ==
    888895{{{
     896#!foxpro
    889897PARAMETERS cfile
    890898PRIVATE ALL
     
    11241132or without using GetHash.dll:
    11251133{{{
     1134#!powershell
    11261135$dataLength = 65536
    11271136
     
    12231232'''OSHashAlgorithm.m'''
    12241233{{{
     1234#!c++
    12251235#import "OSHashAlgorithm.h"
    12261236
     
    13061316'''OSHashAlgorithm.h'''
    13071317{{{
     1318#!c++
    13081319#import <Cocoa/Cocoa.h>
    13091320
     
    13781389== !AutoHotKey ==
    13791390{{{
     1391#!autohotkey
    13801392#NoEnv
    13811393SetBatchLines, -1
     
    14261438; ==================================================================================================
    14271439}}}
     1440
     1441== Lisp ==
     1442{{{
     1443#!lisp
     1444; opensubtitle hash, common lisp, sbcl
     1445; sean langton 2013
     1446
     1447(defun get-lvalue(stream)
     1448  (let ((c)(n 0)(m 1))
     1449    (loop for x from 0 to 7 do
     1450(setf c (read-byte stream))
     1451(setf n (+ n (* c m)))
     1452(setf m (* m 256))
     1453) n))
     1454 
     1455(defun hashfile(path)
     1456  (let ((hash '(unsigned-byte 64))(len))
     1457    (with-open-file (in path :element-type '(unsigned-byte 8))
     1458      (setf len (file-length in))
     1459      (setf hash len)
     1460
     1461      (cond ((< len (* 2 65536))
     1462    (print "file too small to hash")
     1463    (return-from hashfile nil)))
     1464
     1465      (loop for x from 0 to 8191  do
     1466  (setf hash (logand (+ hash (get-lvalue in)) #xFFFFFFFFFFFFFFFF )))
     1467
     1468      (file-position in (- len 65536))
     1469
     1470      (loop for x from 0 to 8191  do
     1471  (setf hash (logand (+ hash (get-lvalue in)) #xFFFFFFFFFFFFFFFF )))
     1472
     1473      (format t "~&~16,'0x" hash))))
     1474
     1475; (hashfile #p"~/Downloads/breakdance.avi")
     1476; (hashfile #p"~/Downloads/dummy/dummy.bin")
     1477}}}