1 import java.io.*; 2 import com.memoire.vainstall.*; 3 import Acme.Crypto.*; 4 17 20 public class HelloLicenseKeySupport extends LicenseKeySupport 21 { 22 String key = "HW0123-4567-89AB-CDEF-8B58-85B7"; 23 String codekey; 24 26 public boolean needsLicenseKey() { 27 return true; 28 } 29 34 35 public String getRegistrationPage() { 36 return "http://www.novosoft-us.com"; 37 } 38 39 42 public FieldInfo[] getFieldInfo() { 43 return new FieldInfo[]{new FieldInfo("serial key", 20, key)}; 44 } 45 50 public void setFieldValues(String values[]) { 51 key = values[0]; 52 } 53 56 public boolean isLicenseKeyValid() 57 { 58 StringBuffer tmp = new StringBuffer (key.toUpperCase()); 59 for(int n = tmp.length(),i=0;i<n;i++) { 60 if(tmp.charAt(i) == '-'){ 61 tmp.deleteCharAt(i); 62 i--; 63 n--; 64 } 65 } 66 String normalized = tmp.toString(); 67 if(normalized.length() < 26) { 68 return false; 69 } 70 codekey = normalized.substring(0,normalized.length()-8); 71 if(codekey.hashCode() != (int)Long.parseLong(normalized.substring(codekey.length(),normalized.length()),16) ){ 72 return false; 73 } 74 return true; 75 } 76 83 public OutputStream encodeStream(OutputStream os, String key) throws IOException 84 { 85 EncryptedOutputStream rc = new EncryptedOutputStream(new AesCipher(key), os); 86 return rc; 87 } 88 92 public InputStream decodeStream(InputStream is) throws IOException 93 { 94 EncryptedInputStream rc = new EncryptedInputStream(new AesCipher(codekey), is); 95 return rc; 96 } 97 98 }
| Popular Tags
|