File: md5.test

package info (click to toggle)
tcltrf 2.1.4-dfsg1-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 8,052 kB
  • sloc: ansic: 72,769; tcl: 1,343; makefile: 226; sh: 89; exp: 22
file content (55 lines) | stat: -rw-r--r-- 1,461 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- tcl -*-
# Commands covered:	md5
#
# This file contains a collection of tests for one or more of the commands
# the TRF extension. Sourcing this file into Tcl runs the tests and generates
# output for errors.  No output means no errors were found.
#
# Copyright (c) 1996 Andreas Kupries (andreas_kupries@users.sourceforge.net)
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# $Id: md5.test,v 1.4 1997/07/22 22:00:43 aku Exp $

if {[string compare test [info procs test]] == 1} then {source defs}


# test suite from RFC 1321 (1..7)


foreach {i in digest} {
    0 {hello world}
    5EB63BBBE01EEED093CB22BB8F5ACDC3

    1 {}
    d41d8cd98f00b204e9800998ecf8427e

    2 a
    0cc175b9c0f1b6a831c399e269772661

    3 abc
    900150983cd24fb0d6963f7d28e17f72

    4 {message digest}
    f96b697d7cb7938d525a2f31aaf161d0

    5 abcdefghijklmnopqrstuvwxyz
    c3fcd3d76192e4007dfb496cca67e13b

    6 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
    d174ab98d277d9f5a5611c2c9f419d9f

    7 12345678901234567890123456789012345678901234567890123456789012345678901234567890
    57edf4a22be3c955ac49da2e2107b67a
} {
    if {[info tclversion] < 8.0} {
	test md5-4.$i-7.6 {md5, immediate} {
	    exec_md md5 [text2hex $in]
	} [string toupper $digest]
    } else {
	test md5-4.$i-8.x {md5, immediate} {
	    hex -m e [md5 $in]
	} [string toupper $digest]
    }
}