Back to project page exchange-android.
The source code is released under:
MIT License
If you think the Android project exchange-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package edu.cmu.cylab.starslinger.exchange; /*ww w. j a va 2s . c o m*/ /* * The MIT License (MIT) * * Copyright (c) 2010-2014 Carnegie Mellon University * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class WordList { // Hex, Even Word, Odd Word public static WordPair[] wordList = { new WordPair(0x00, "aardvark", "adroitness"), // new WordPair(0x01, "absurd", "adviser"), // new WordPair(0x02, "accrue", "aftermath"), // new WordPair(0x03, "acme", "aggregate"), // new WordPair(0x04, "adrift", "alkali"), // new WordPair(0x05, "adult", "almighty"), // new WordPair(0x06, "afflict", "amulet"), // new WordPair(0x07, "ahead", "amusement"), // new WordPair(0x08, "aimless", "antenna"), // new WordPair(0x09, "Algol", "applicant"), // new WordPair(0x0A, "allow", "Apollo"), // new WordPair(0x0B, "alone", "armistice"), // new WordPair(0x0C, "ammo", "article"), // new WordPair(0x0D, "ancient", "asteroid"), // new WordPair(0x0E, "apple", "Atlantic"), // new WordPair(0x0F, "artist", "atmosphere"), // new WordPair(0x10, "assume", "autopsy"), // new WordPair(0x11, "Athens", "Babylon"), // new WordPair(0x12, "atlas", "backwater"), // new WordPair(0x13, "Aztec", "barbecue"), // new WordPair(0x14, "baboon", "belowground"), // new WordPair(0x15, "backfield", "bifocals"), // new WordPair(0x16, "backward", "bodyguard"), // new WordPair(0x17, "banjo", "bookseller"), // new WordPair(0x18, "beaming", "borderline"), // new WordPair(0x19, "bedlamp", "bottomless"), // new WordPair(0x1A, "beehive", "Bradbury"), // new WordPair(0x1B, "beeswax", "bravado"), // new WordPair(0x1C, "befriend", "Brazilian"), // new WordPair(0x1D, "Belfast", "breakaway"), // new WordPair(0x1E, "berserk", "Burlington"), // new WordPair(0x1F, "billiard", "businessman"), // new WordPair(0x20, "bison", "butterfat"), // new WordPair(0x21, "blackjack", "Camelot"), // new WordPair(0x22, "blockade", "candidate"), // new WordPair(0x23, "blowtorch", "cannonball"), // new WordPair(0x24, "bluebird", "Capricorn"), // new WordPair(0x25, "bombast", "caravan"), // new WordPair(0x26, "bookshelf", "caretaker"), // new WordPair(0x27, "brackish", "celebrate"), // new WordPair(0x28, "breadline", "cellulose"), // new WordPair(0x29, "breakup", "certify"), // new WordPair(0x2A, "brickyard", "chambermaid"), // new WordPair(0x2B, "briefcase", "Cherokee"), // new WordPair(0x2C, "Burbank", "Chicago"), // new WordPair(0x2D, "button", "clergyman"), // new WordPair(0x2E, "buzzard", "coherence"), // new WordPair(0x2F, "cement", "combustion"), // new WordPair(0x30, "chairlift", "commando"), // new WordPair(0x31, "chatter", "company"), // new WordPair(0x32, "checkup", "component"), // new WordPair(0x33, "chisel", "concurrent"), // new WordPair(0x34, "choking", "confidence"), // new WordPair(0x35, "chopper", "conformist"), // new WordPair(0x36, "Christmas", "congregate"), // new WordPair(0x37, "clamshell", "consensus"), // new WordPair(0x38, "classic", "consulting"), // new WordPair(0x39, "classroom", "corporate"), // new WordPair(0x3A, "cleanup", "corrosion"), // new WordPair(0x3B, "clockwork", "councilman"), // new WordPair(0x3C, "cobra", "crossover"), // new WordPair(0x3D, "commence", "crucifix"), // new WordPair(0x3E, "concert", "cumbersome"), // new WordPair(0x3F, "cowbell", "customer"), // new WordPair(0x40, "crackdown", "Dakota"), // new WordPair(0x41, "cranky", "decadence"), // new WordPair(0x42, "crowfoot", "December"), // new WordPair(0x43, "crucial", "decimal"), // new WordPair(0x44, "crumpled", "designing"), // new WordPair(0x45, "crusade", "detector"), // new WordPair(0x46, "cubic", "detergent"), // new WordPair(0x47, "dashboard", "determine"), // new WordPair(0x48, "deadbolt", "dictator"), // new WordPair(0x49, "deckhand", "dinosaur"), // new WordPair(0x4A, "dogsled", "direction"), // new WordPair(0x4B, "dragnet", "disable"), // new WordPair(0x4C, "drainage", "disbelief"), // new WordPair(0x4D, "dreadful", "disruptive"), // new WordPair(0x4E, "drifter", "distortion"), // new WordPair(0x4F, "dropper", "document"), // new WordPair(0x50, "drumbeat", "embezzle"), // new WordPair(0x51, "drunken", "enchanting"), // new WordPair(0x52, "Dupont", "enrollment"), // new WordPair(0x53, "dwelling", "enterprise"), // new WordPair(0x54, "eating", "equation"), // new WordPair(0x55, "edict", "equipment"), // new WordPair(0x56, "egghead", "escapade"), // new WordPair(0x57, "eightball", "Eskimo"), // new WordPair(0x58, "endorse", "everyday"), // new WordPair(0x59, "endow", "examine"), // new WordPair(0x5A, "enlist", "existence"), // new WordPair(0x5B, "erase", "exodus"), // new WordPair(0x5C, "escape", "fascinate"), // new WordPair(0x5D, "exceed", "filament"), // new WordPair(0x5E, "eyeglass", "finicky"), // new WordPair(0x5F, "eyetooth", "forever"), // new WordPair(0x60, "facial", "fortitude"), // new WordPair(0x61, "fallout", "frequency"), // new WordPair(0x62, "flagpole", "gadgetry"), // new WordPair(0x63, "flatfoot", "Galveston"), // new WordPair(0x64, "flytrap", "getaway"), // new WordPair(0x65, "fracture", "glossary"), // new WordPair(0x66, "framework", "gossamer"), // new WordPair(0x67, "freedom", "graduate"), // new WordPair(0x68, "frighten", "gravity"), // new WordPair(0x69, "gazelle", "guitarist"), // new WordPair(0x6A, "Geiger", "hamburger"), // new WordPair(0x6B, "glitter", "Hamilton"), // new WordPair(0x6C, "glucose", "handiwork"), // new WordPair(0x6D, "goggles", "hazardous"), // new WordPair(0x6E, "goldfish", "headwaters"), // new WordPair(0x6F, "gremlin", "hemisphere"), // new WordPair(0x70, "guidance", "hesitate"), // new WordPair(0x71, "hamlet", "hideaway"), // new WordPair(0x72, "highchair", "holiness"), // new WordPair(0x73, "hockey", "hurricane"), // new WordPair(0x74, "indoors", "hydraulic"), // new WordPair(0x75, "indulge", "impartial"), // new WordPair(0x76, "inverse", "impetus"), // new WordPair(0x77, "involve", "inception"), // new WordPair(0x78, "island", "indigo"), // new WordPair(0x79, "jawbone", "inertia"), // new WordPair(0x7A, "keyboard", "infancy"), // new WordPair(0x7B, "kickoff", "inferno"), // new WordPair(0x7C, "kiwi", "informant"), // new WordPair(0x7D, "klaxon", "insincere"), // new WordPair(0x7E, "locale", "insurgent"), // new WordPair(0x7F, "lockup", "integrate"), // new WordPair(0x80, "merit", "intention"), // new WordPair(0x81, "minnow", "inventive"), // new WordPair(0x82, "miser", "Istanbul"), // new WordPair(0x83, "Mohawk", "Jamaica"), // new WordPair(0x84, "mural", "Jupiter"), // new WordPair(0x85, "music", "leprosy"), // new WordPair(0x86, "necklace", "letterhead"), // new WordPair(0x87, "Neptune", "liberty"), // new WordPair(0x88, "newborn", "maritime"), // new WordPair(0x89, "nightbird", "matchmaker"), // new WordPair(0x8A, "Oakland", "maverick"), // new WordPair(0x8B, "obtuse", "Medusa"), // new WordPair(0x8C, "offload", "megaton"), // new WordPair(0x8D, "optic", "microscope"), // new WordPair(0x8E, "orca", "microwave"), // new WordPair(0x8F, "payday", "midsummer"), // new WordPair(0x90, "peachy", "millionaire"), // new WordPair(0x91, "pheasant", "miracle"), // new WordPair(0x92, "physique", "misnomer"), // new WordPair(0x93, "playhouse", "molasses"), // new WordPair(0x94, "Pluto", "molecule"), // new WordPair(0x95, "preclude", "Montana"), // new WordPair(0x96, "prefer", "monument"), // new WordPair(0x97, "preshrunk", "mosquito"), // new WordPair(0x98, "printer", "narrative"), // new WordPair(0x99, "prowler", "nebula"), // new WordPair(0x9A, "pupil", "newsletter"), // new WordPair(0x9B, "puppy", "Norwegian"), // new WordPair(0x9C, "python", "October"), // new WordPair(0x9D, "quadrant", "Ohio"), // new WordPair(0x9E, "quiver", "onlooker"), // new WordPair(0x9F, "quota", "opulent"), // new WordPair(0xA0, "ragtime", "Orlando"), // new WordPair(0xA1, "ratchet", "outfielder"), // new WordPair(0xA2, "rebirth", "Pacific"), // new WordPair(0xA3, "reform", "pandemic"), // new WordPair(0xA4, "regain", "Pandora"), // new WordPair(0xA5, "reindeer", "paperweight"), // new WordPair(0xA6, "rematch", "paragon"), // new WordPair(0xA7, "repay", "paragraph"), // new WordPair(0xA8, "retouch", "paramount"), // new WordPair(0xA9, "revenge", "passenger"), // new WordPair(0xAA, "reward", "pedigree"), // new WordPair(0xAB, "rhythm", "Pegasus"), // new WordPair(0xAC, "ribcage", "penetrate"), // new WordPair(0xAD, "ringbolt", "perceptive"), // new WordPair(0xAE, "robust", "performance"), // new WordPair(0xAF, "rocker", "pharmacy"), // new WordPair(0xB0, "ruffled", "phonetic"), // new WordPair(0xB1, "sailboat", "photograph"), // new WordPair(0xB2, "sawdust", "pioneer"), // new WordPair(0xB3, "scallion", "pocketful"), // new WordPair(0xB4, "scenic", "politeness"), // new WordPair(0xB5, "scorecard", "positive"), // new WordPair(0xB6, "Scotland", "potato"), // new WordPair(0xB7, "seabird", "processor"), // new WordPair(0xB8, "select", "provincial"), // new WordPair(0xB9, "sentence", "proximate"), // new WordPair(0xBA, "shadow", "puberty"), // new WordPair(0xBB, "shamrock", "publisher"), // new WordPair(0xBC, "showgirl", "pyramid"), // new WordPair(0xBD, "skullcap", "quantity"), // new WordPair(0xBE, "skydive", "racketeer"), // new WordPair(0xBF, "slingshot", "rebellion"), // new WordPair(0xC0, "slowdown", "recipe"), // new WordPair(0xC1, "snapline", "recover"), // new WordPair(0xC2, "snapshot", "repellent"), // new WordPair(0xC3, "snowcap", "replica"), // new WordPair(0xC4, "snowslide", "reproduce"), // new WordPair(0xC5, "solo", "resistor"), // new WordPair(0xC6, "southward", "responsive"), // new WordPair(0xC7, "soybean", "retraction"), // new WordPair(0xC8, "spaniel", "retrieval"), // new WordPair(0xC9, "spearhead", "retrospect"), // new WordPair(0xCA, "spellbind", "revenue"), // new WordPair(0xCB, "spheroid", "revival"), // new WordPair(0xCC, "spigot", "revolver"), // new WordPair(0xCD, "spindle", "sandalwood"), // new WordPair(0xCE, "spyglass", "sardonic"), // new WordPair(0xCF, "stagehand", "Saturday"), // new WordPair(0xD0, "stagnate", "savagery"), // new WordPair(0xD1, "stairway", "scavenger"), // new WordPair(0xD2, "standard", "sensation"), // new WordPair(0xD3, "stapler", "sociable"), // new WordPair(0xD4, "steamship", "souvenir"), // new WordPair(0xD5, "sterling", "specialist"), // new WordPair(0xD6, "stockman", "speculate"), // new WordPair(0xD7, "stopwatch", "stethoscope"), // new WordPair(0xD8, "stormy", "stupendous"), // new WordPair(0xD9, "sugar", "supportive"), // new WordPair(0xDA, "surmount", "surrender"), // new WordPair(0xDB, "suspense", "suspicious"), // new WordPair(0xDC, "sweatband", "sympathy"), // new WordPair(0xDD, "swelter", "tambourine"), // new WordPair(0xDE, "tactics", "telephone"), // new WordPair(0xDF, "talon", "therapist"), // new WordPair(0xE0, "tapeworm", "tobacco"), // new WordPair(0xE1, "tempest", "tolerance"), // new WordPair(0xE2, "tiger", "tomorrow"), // new WordPair(0xE3, "tissue", "torpedo"), // new WordPair(0xE4, "tonic", "tradition"), // new WordPair(0xE5, "topmost", "travesty"), // new WordPair(0xE6, "tracker", "trombonist"), // new WordPair(0xE7, "transit", "truncated"), // new WordPair(0xE8, "trauma", "typewriter"), // new WordPair(0xE9, "treadmill", "ultimate"), // new WordPair(0xEA, "Trojan", "undaunted"), // new WordPair(0xEB, "trouble", "underfoot"), // new WordPair(0xEC, "tumor", "unicorn"), // new WordPair(0xED, "tunnel", "unify"), // new WordPair(0xEE, "tycoon", "universe"), // new WordPair(0xEF, "uncut", "unravel"), // new WordPair(0xF0, "unearth", "upcoming"), // new WordPair(0xF1, "unwind", "vacancy"), // new WordPair(0xF2, "uproot", "vagabond"), // new WordPair(0xF3, "upset", "vertigo"), // new WordPair(0xF4, "upshot", "Virginia"), // new WordPair(0xF5, "vapor", "visitor"), // new WordPair(0xF6, "village", "vocalist"), // new WordPair(0xF7, "virus", "voyager"), // new WordPair(0xF8, "Vulcan", "warranty"), // new WordPair(0xF9, "waffle", "Waterloo"), // new WordPair(0xFA, "wallet", "whimsical"), // new WordPair(0xFB, "watchword", "Wichita"), // new WordPair(0xFC, "wayside", "Wilmington"), // new WordPair(0xFD, "willow", "Wyoming"), // new WordPair(0xFE, "woodlark", "yesteryear"), // new WordPair(0xFF, "Zulu", "Yucatan"), // }; public static String getWord(byte hex, boolean even) { // bytes are unsigned, shift the int if (even) return wordList[btoi(hex)].EvenWord; return wordList[btoi(hex)].OddWord; } public static int btoi(byte b) { return b & 0x000000FF; } public static byte itob(int i) { byte newVal = Integer.valueOf(i).byteValue(); return newVal; } public static String getWordList(byte[] hash, int length) { StringBuilder hashList = new StringBuilder(); for (int i = 0; i < length; i++) { hashList.append(WordList.getWord(hash[i], (i % 2 == 0))); hashList.append(" "); } return hashList.toString().trim(); } public static String getNumbersList(byte[] hash, int length) { StringBuilder hashList = new StringBuilder(); for (int i = 0; i < length; i++) { int number = WordList.btoi(hash[i]); // even = 1-256, odd = 257-512 hashList.append(((i % 2 == 0) ? number : (number + 256)) + 1); hashList.append(" "); } return hashList.toString().trim(); } }