Add unobfuscated code from @SirWumpus

The entries 2004/hibachi and 2005/mynx have unobfuscated code now.

2004/hibachi has a configure script that is used along the lines of the
original entry (with some adjustments and fixes) and the hibachi.alt.c
had to have ctype.h included too. The directory src/localhost was copied
to src-alt/localhost but the rest of src/ was from Anthony. The Makefile
had to be updated to build this version.

2005/mynx does have a configure script but it is, just like the original
entry, unused and so the unobfuscated (in source-alt/) is also unused.
The mynx.alt.c was changed to mynx.alt2.c and the unobfuscated code was
made mynx.alt.c.

Updated manifest, rebuilt .entry.json and index.html files.

After a question is answered and taken care of (in one of 199[1-3]/ant -
not sure which one) issue #2513 can possibly be closed as complete
(though the manifest updates will have to be looked at more when 2004
and 2005 are reviewed).
This commit is contained in:
Cody Boone Ferguson committed 2024-07-08 13:11:00 -07:00
1 parent 60ce3d9155
commit 0d65af1b2b
65 files changed
+15579 -218

No files matched your search

@@ -0,0 +1,150 @@
#
# LUHN.rb
#
# Copyright 2000, 2004 by Anthony Howe. All rights reserved.
#
class LUHN
def LUHN.base(str, radix)
if radix < 2 then
return nil
end
num = 0
str.downcase!
str.each_byte do |byte|
i = "0123456789abcdefghijklmnopqrstuvwxyz".index(byte)
if i.nil? || radix <= i then
return nil
end
num = num * radix + i
end
return num
end
#
# Internal routine that computes the LUHN sum.
#
# The LUHN Algorithm ("mod 10 Double-Add-Double"):
#
# 1. Position from right 8 7 6 5 4 3 2 1
# ------------------------------
# Number string 4 8 9 5 1 3 1 3
# x2 even positions 2 1 2 1 2 1 2 1
# ------------------------------
# Add odd positions & 8 +8 +1+8 +5 +2 +3 +2 +3
# add digits of doubled
# positions
#
# Sum 40
#
# Number is valid if sum is a multiple of 10.
#
#
# 2. Alpha-numeric ISIN U S 3 8 3 8 8 3 1 0 5 1
# (ISO 6166) -----------------------------------------
# base 36 digits 30 28 3 8 3 8 8 3 1 0 5 1
# -----------------------------------------
# consider digit string 3 0 2 8 3 8 3 8 8 3 1 0 5 1
# & x2 even digits from 2 1 2 1 2 1 2 1 2 1 2 1 2 1
# -----------------------------------------
# 6 0 4 8 6 8 6 8 16 3 2 0 10 1
# -----------------------------------------
# sum the digits of 6 +0 +4 +8 +6 +8 +6 +8+1+6+3 +2 +0+1+0+1
#
# Sum 60
#
# Number is valid if sum is a multiple of 10.
#
def LUHN.sum(str)
if ! str.instance_of?(String) || str.length < 1 then
return nil
end
total = 0
even = false
str = str.reverse.downcase
# Working right to left...
str.each_byte do |byte|
# Convert base36 digit to a base10 value.
digit36 = base(byte.chr, 36)
if digit36.nil? then
return nil
end
# For each base10 digit of a base36 digit...
begin
digit10 = digit36 % 10
if even then
# Multiply even digits by 2.
digit10 <<= 1
# Sum digits of product.
if 10 <= digit10 then
digit10 -= 9
end
end
# Add digits of product to total.
total += digit10
# Next digit.
digit36 = (digit36 / 10).floor
# Toggle from digit to digit.
even = !even
end while 0 < digit36
end
return total
end
#
# Return true if the string of digits is valid.
# Assumes LUHN check digit is right most digit.
#
def LUHN.valid?(str)
if ! str.instance_of?(String) || str.length < 2 then
return false
end
total = sum(str)
return total.nil? ? false : (total % 10) == 0
end
#
# Return the LUHN check digit (mod 10) for the
# given string of digits; otherwise nil on error.
#
def LUHN.generate(str)
if ! str.instance_of?(String) || str.length < 1 then
return nil
end
total = sum(str + '0')
return total.nil? ? nil : (10 - (total % 10)) % 10
end
end
if $DEBUG && $0 == 'LUHN.rb' then
def generate(str, expect)
digit = LUHN.generate(str)
puts(str + "-" + digit.to_s + ' ' + (digit == expect).to_s)
end
def validate(str)
puts(str + ' ' + LUHN.valid?(str).to_s)
end
generate('1', 8)
generate('12', 5)
generate('123', 0)
generate('A', 9)
generate('AB', 6)
validate('AB6')
end
+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/ruby
require 'cgi'
require ENV['DOCUMENT_ROOT'] + '/test/ruby/LUHN'
if ENV['QUERY_STRING'].nil? then
answer = ''
numebr = ''
else
query = CGI.parse(ENV['QUERY_STRING'])
number = query['number'].to_s
case query['action'].to_s
when 'Validate'
is_valid = LUHN.valid?(number)
answer = number
when 'Generate'
digit = LUHN.generate(number)
answer = "#{number}" + digit.to_s
is_valid = ! digit.nil?
end
end
puts <<"EOT"
HTTP/1.0 200 OK
Content-Type: text/html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>
Hibachi - Playing with LUHN checksums in Ruby
</title>
</head>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="130">
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
</td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="500">
<tr>
<td>
<h2>Playing with LUHN checksums in Ruby<br/>"mod 10 Double-Add-Double"</h2>
<p>Enter an alpha-numeric string like a credit card number or International Securities Identification Number (ISO 6166).
Click validate to test if the entered string is correct. Click generate to append the check digit to the string.
</p>
<form name="luhn" method="GET" action="index.rb">
<textarea name="number" wrap="virtual" rows="2" cols="30">#{answer}</textarea>
<br/><b>#{ is_valid ? "Is valid." : "Is NOT valid." }</b>
<br/>
<br/>
<input type="submit" name="action" value="Validate">
&nbsp;&nbsp;
<input type="submit" name="action" value="Generate">
&nbsp;&nbsp;
<input type="button" value="Clear" onclick="this.form.number.value = ''">
</form>
<hr>
<a href="../../#Test">Return to HIBACHI</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
EOT
exit(0)
@@ -0,0 +1,80 @@
#!@ruby_exe@
require 'cgi'
require ENV['DOCUMENT_ROOT'] + '/test/ruby/LUHN'
if ENV['QUERY_STRING'].nil? then
answer = ''
numebr = ''
else
query = CGI.parse(ENV['QUERY_STRING'])
number = query['number'].to_s
case query['action'].to_s
when 'Validate'
is_valid = LUHN.valid?(number)
answer = number
when 'Generate'
digit = LUHN.generate(number)
answer = "#{number}" + digit.to_s
is_valid = ! digit.nil?
end
end
puts <<"EOT"
HTTP/1.0 200 OK
Content-Type: text/html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>
Hibachi - Playing with LUHN checksums in Ruby
</title>
</head>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="130">
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
</td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="500">
<tr>
<td>
<h2>Playing with LUHN checksums in Ruby<br/>"mod 10 Double-Add-Double"</h2>
<p>Enter an alpha-numeric string like a credit card number or International Securities Identification Number (ISO 6166).
Click validate to test if the entered string is correct. Click generate to append the check digit to the string.
</p>
<form name="luhn" method="GET" action="index.rb">
<textarea name="number" wrap="virtual" rows="2" cols="30">#{answer}</textarea>
<br/><b>#{ is_valid ? "Is valid." : "Is NOT valid." }</b>
<br/>
<br/>
<input type="submit" name="action" value="Validate">
&nbsp;&nbsp;
<input type="submit" name="action" value="Generate">
&nbsp;&nbsp;
<input type="button" value="Clear" onclick="this.form.number.value = ''">
</form>
<hr>
<a href="../../#Test">Return to HIBACHI</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
EOT
exit(0)