From: Robert K. <may...@us...> - 2001-12-17 22:32:56
|
Update of /cvsroot/bitcollider/jbitprint/src/com/bitzi/bitprint In directory usw-pr-cvs1:/tmp/cvs-serv31319/src/com/bitzi/bitprint Modified Files: Base32.java BitprintTest.java Log Message: Updated for the new character set and the dot. Index: Base32.java =================================================================== RCS file: /cvsroot/bitcollider/jbitprint/src/com/bitzi/bitprint/Base32.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Base32.java 2001/09/24 23:07:52 1.1 --- Base32.java 2001/12/17 22:32:52 1.2 *************** *** 13,18 **** public class Base32 { ! private static final int bitprintBase32Len = 71; private static final int bitprintRawLen = 44; private static final int bufferLen = 4096; --- 13,20 ---- public class Base32 { ! private static final int bitprintBase32Len = 72; private static final int bitprintRawLen = 44; + private static final int shaBase32Len = 32; + private static final int tigerBase32Len = 39; private static final int bufferLen = 4096; *************** *** 20,70 **** private static final int base32LookupMax = 32; private static final String base32Chars = ! "ABCDEFGHIJKMNPQRSTUVWXYZ23456789"; private static final int[][] base32Lookup = { ! { '0', 0xFF, }, ! { '1', 0xFF, }, ! { '2', 0x18, }, ! { '3', 0x19, }, ! { '4', 0x1A, }, ! { '5', 0x1B, }, ! { '6', 0x1C, }, ! { '7', 0x1D, }, ! { '8', 0x1E, }, ! { '9', 0x1F, }, ! { ':', 0xFF, }, ! { ';', 0xFF, }, ! { '<', 0xFF, }, ! { '=', 0xFF, }, ! { '>', 0xFF, }, ! { '?', 0xFF, }, ! { '@', 0xFF, }, ! { 'A', 0x00, }, ! { 'B', 0x01, }, ! { 'C', 0x02, }, ! { 'D', 0x03, }, ! { 'E', 0x04, }, ! { 'F', 0x05, }, ! { 'G', 0x06, }, ! { 'H', 0x07, }, ! { 'I', 0x08, }, ! { 'J', 0x09, }, ! { 'K', 0x0A, }, ! { 'L', 0xFF, }, ! { 'M', 0x0B, }, ! { 'N', 0x0C, }, ! { 'O', 0xFF, }, ! { 'P', 0x0D, }, ! { 'Q', 0x0E, }, ! { 'R', 0x0F, }, ! { 'S', 0x10, }, ! { 'T', 0x11, }, ! { 'U', 0x12, }, ! { 'V', 0x13, }, ! { 'W', 0x14, }, ! { 'X', 0x15, }, ! { 'Y', 0x16, }, ! { 'Z', 0x17 } }; --- 22,72 ---- private static final int base32LookupMax = 32; private static final String base32Chars = ! "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; private static final int[][] base32Lookup = { ! { '0', 0xFF }, ! { '1', 0xFF }, ! { '2', 0x1A }, ! { '3', 0x1B }, ! { '4', 0x1C }, ! { '5', 0x1D }, ! { '6', 0x1E }, ! { '7', 0x1F }, ! { '8', 0xFF }, ! { '9', 0xFF }, ! { ':', 0xFF }, ! { ';', 0xFF }, ! { '<', 0xFF }, ! { '=', 0xFF }, ! { '>', 0xFF }, ! { '?', 0xFF }, ! { '@', 0xFF }, ! { 'A', 0x00 }, ! { 'B', 0x01 }, ! { 'C', 0x02 }, ! { 'D', 0x03 }, ! { 'E', 0x04 }, ! { 'F', 0x05 }, ! { 'G', 0x06 }, ! { 'H', 0x07 }, ! { 'I', 0x08 }, ! { 'J', 0x09 }, ! { 'K', 0x0A }, ! { 'L', 0x0B }, ! { 'M', 0x0C }, ! { 'N', 0x0D }, ! { 'O', 0x0E }, ! { 'P', 0x0F }, ! { 'Q', 0x10 }, ! { 'R', 0x11 }, ! { 'S', 0x12 }, ! { 'T', 0x13 }, ! { 'U', 0x14 }, ! { 'V', 0x15 }, ! { 'W', 0x16 }, ! { 'X', 0x17 }, ! { 'Y', 0x18 }, ! { 'Z', 0x19 } }; *************** *** 73,82 **** public String bitprintToBase32(final byte[] digest) { ! return encodeBase32(digest, bitprintRawLen); } public byte[] bitprintFromBase32(final String bitprint) { ! return decodeBase32(bitprint, bitprintBase32Len); } --- 75,92 ---- public String bitprintToBase32(final byte[] digest) { ! String bitprint; ! ! bitprint = encodeBase32(digest, bitprintRawLen); ! return bitprint.substring(0, shaBase32Len) + '.' + ! bitprint.substring(shaBase32Len, bitprintBase32Len - 1); } public byte[] bitprintFromBase32(final String bitprint) { ! String pureBase32; ! ! pureBase32 = bitprint.substring(0, shaBase32Len) + ! bitprint.substring(shaBase32Len + 1, bitprintBase32Len); ! return decodeBase32(pureBase32, bitprintBase32Len); } Index: BitprintTest.java =================================================================== RCS file: /cvsroot/bitcollider/jbitprint/src/com/bitzi/bitprint/BitprintTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** BitprintTest.java 2001/09/24 23:07:50 1.1 --- BitprintTest.java 2001/12/17 22:32:52 1.2 *************** *** 42,46 **** hash = convert.bitprintToBase32(digest); ! System.out.println(hash); } } --- 42,51 ---- hash = convert.bitprintToBase32(digest); ! System.out.println("Base32Bitprint:"); ! System.out.println(" " + hash); ! ! hash = convert.bitprintToBase32(convert.bitprintFromBase32(hash)); ! System.out.println("Double check:"); ! System.out.println(" " + hash); } } |