59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
}
return $ret
}
# Convert a string into a C-style binary string
## XXX: This function needs to be optimized
proc stringify {data} {
set ret "\""
for {set idx 0} {$idx < [string length $data]} {incr idx} {
binary scan [string index $data $idx] H* char
append ret "\\x${char}"
if {($idx % 20) == 0 && $idx != 0} {
append ret "\"\n\""
}
}
set ret [string trim $ret "\n\""]
set ret "\"$ret\""
return $ret
}
# Encrypt the data
proc random_byte {} {
set value [expr {int(256 * rand())}]
|
>
>
>
>
>
>
>
>
|
>
|
|
|
<
|
<
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
}
return $ret
}
# Convert a string into a C-style binary string
## XXX: This function needs to be optimized
proc stringify_putsOrAppend {var fd data} {
if {$fd eq ""} {
uplevel 1 [list append $var $data]
} else {
puts -nonewline $fd $data
}
}
proc stringify {data {outfd ""}} {
stringify_putsOrAppend ret $outfd "\""
for {set idx 0} {$idx < [string length $data]} {incr idx} {
binary scan [string index $data $idx] H* char
stringify_putsOrAppend ret $outfd "\\x${char}"
if {($idx % 20) == 0 && $idx != 0} {
stringify_putsOrAppend ret $outfd "\"\n\""
}
}
stringify_putsOrAppend ret $outfd "\""
return $ret
}
# Encrypt the data
proc random_byte {} {
set value [expr {int(256 * rand())}]
|